I'm trying to reverse engineer protocol for unknown IP camera, so I can control it.
I'm using Python 2.7 because I have managed to find some python code that is talking to camera, but need to add functionality.
This is the code that is working fine:
data='{ "Name" : "OPTimeQuery", "SessionID" : "0x00000006" }'
msg='1452'
self.socket.send(struct.pack('BB2xII2xHI',255, 0, 6, 1, msg ,len(data)+2)+data+"\x0a\x00")
And I get:
ff00000006000000140000000000ac05370000007b20224e616d6522203a20224f5054696d655175657279222c202253657373696f6e494422203a20223078303030303030303622207d0a00
My problem is decoding this back. This is the code that does not work:
binary=binascii.unhexlify('ff00000006000000140000000000ac05370000007b20224e616d6522203a20224f5054696d655175657279222c202253657373696f6e494422203a20223078303030303030303622207d0a00')
print struct.unpack('BB2xII2xHI',binary[:20])
struct.error: unpack requires a string argument of length 20
The end goal is to get to the msg variable that was used for example here:
ff000000060000001800000000001004490200007b202243616d6572612e506172616d2e5b305d22203a207b2022416553656e736974697669747922203a20372c202241706572747572654d6f646522203a202230783030303030303031222c2022424c434d6f646522203a202230783030303030303031222c20224461794e69676874436f6c6f7222203a202230783030303030303030222c20224461795f6e664c6576656c22203a20332c2022446e6354687222203a2033302c2022456c65634c6576656c22203a2035302c202245735368757474657222203a202230783030303030303036222c20224578706f73757265506172616d22203a207b20224c6561737454696d6522203a202230783030303030303634222c20224c6576656c22203a20302c20224d6f737454696d6522203a20223078303030313030303022207d2c20224761696e506172616d22203a207b20224175746f4761696e22203a20302c20224761696e22203a203530207d2c202249524355544d6f646522203a20312c202249726375745377617022203a20302c20224e696768745f6e664c6576656c22203a20332c202250696374757265466c697022203a202230783030303030303031222c2022506963747572654d6972726f7222203a202230783030303030303031222c202252656a656374466c69636b657222203a202230783030303030303030222c2022576869746542616c616e636522203a20223078303030303030303022207d2c20224e616d6522203a202243616d6572612e506172616d2e5b305d222c202253657373696f6e494422203a202230783622207d0a
User contributions licensed under CC BY-SA 3.0