Hallo,
ich lade mit einem Code KOnfigurationsdaten einer IP Kamera hoch.
Nun habe ich im upload 3 Hex zeichen am Anfang, wo ich nicht weiß, woher die kommen.
Public Function UpdateConfig(ByVal strUploadfile As String, ByVal IP As String, _
ByVal User As String, ByVal Passwort As String) As String
** SNIPP ***
Dim sb1 As New StringBuilder
sb1.Append(vbCrLf)
' sb1.Append("--")
sb1.Append(boundary)
sb1.Append(vbCrLf)
sb1.Append("Content-Disposition: form-data; name=""")
sb1.Append("CONFIG_SUBMIT")
sb1.Append(Chr(34))
sb1.Append(vbCrLf)
sb1.Append(vbCrLf)
sb1.Append("Apply")
'sb1.Append(vbCrLf)
Dim postFoot As String = sb1.ToString()
Dim postFootBytes As Byte() = Encoding.ASCII.GetBytes(postFoot)
' Build the trailing boundary string as a byte array
' ensuring the boundary appears on a line by itself
Dim boundaryBytes As Byte() = Encoding.ASCII.GetBytes(vbCrLf & "--" & _
boundary & "--" & vbCrLf)
'open file to upload
Dim fileStream As New FileStream(strUploadfile, FileMode.Open, _
FileAccess.Read)
'calculate length of POST
Dim length As Long = postHeaderBytes.Length + fileStream.Length + _
postFootBytes.Length + boundaryBytes.Length
webrequest.ContentLength = length
'contact server with POST 1.0
Dim requestStream As Stream = webrequest.GetRequestStream()
' Write out header to server
requestStream.Write(postHeaderBytes, 0, postHeaderBytes.Length)
''Application.DoEvents()
' Write out the file contents to server in chunks of 4K
Dim buffer() As Byte
ReDim buffer(Math.Min(4095, fileStream.Length))
Dim bytesRead = 1 'initialize to any number except 0
While bytesRead <> 0
bytesRead = fileStream.Read(buffer, 0, buffer.Length)
If bytesRead <> 0 Then 'make sure EOF is not reached
requestStream.Write(buffer, 0, bytesRead)
End If
''Application.DoEvents()
End While
requestStream.Write(postFootBytes, 0, postFootBytes.Length)
' Write out the trailing boundary
requestStream.Write(boundaryBytes, 0, boundaryBytes.Length)
requestStream.Close()
'collect server response & convert to ASCII
Dim responce As WebResponse = webrequest.GetResponse()
Dim s As Stream = responce.GetResponseStream()
Dim sr As New StreamReader(s)
Return sr.ReadToEnd()
End Function Wenn ich im Wireshark mitschaue, uploaded er:
ACCOUNT_NAME_1='admin'
ACCOUNT_PWD_1='123456'
ACCOUNT_NAME_2=''
ACCOUNT_PWD_2=''
ACCOUNT_NAME_3=''
ACCOUNT_PWD_3=''
statt
ACCOUNT_NAME_1='admin'
ACCOUNT_PWD_1='123456'
ACCOUNT_NAME_2=''
ACCOUNT_PWD_2=''
ACCOUNT_NAME_3=''
ACCOUNT_PWD_3=''
Er fügt drei Hexzeichen dem TXT File voran (ef bb bf) sodass die Kamera jedesmal chrast.
Weiß jemand woher die 3 Hex zeichen kommen? Im TXT File sind die nicht drinnen. Dieses beginnt mit ACCOUNT......
Vielen Dank! |