Comments (13)
Leave this with me, I think I understand now, the program doesn't create a new devParam.dat file, it modifies an existing file.
from zsgx1hacks.
Interesting .
Please post how to calculate checksum so it would be accessible to anyone that is interested
from zsgx1hacks.
Here the CRC calculation (delphi)
program datcrc;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
procedure BufWriteData(buf:PByte; bufsz, from, sz:Int64; const data:string);
var rb:RawByteString;
begin
if bufsz<from+sz then raise Exception.Create('Bad data size');
fillchar(PByte(buf+from)^,sz,0);
rb:=RawByteString(data); //Unicode string to 8bit string
if length(rb)<sz then sz:=length(rb);
Move(rb[1],PByte(buf+from)^,sz);
end;
//devParam.dat size 3*4 + 1024 = 1036
// 0x0000 UINT 0x20150910 date ???
// 0x0004 UINT data crc data word sum - 32bit sum of 16bit words
// 0x0008 UINT data size 0x00000400 = 1024
// 0x000C char(size) data
// ...
// 0x0128 pansichar SSID
// ...
// 0x0154 pansichar password
// ...
// 0x01FC pansichar username (admin)???
// ...
procedure UpdateWiFi(const fname,ssid,pass:string);
var fsz,bsz,cnt,i,crc:longint;
fh:THandle;
buf:PByte;
const
CRCPOS = $0004;
SIZEPOS = $0008;
DATASTART = $000C;
SSIDPOS = $0128;
SSIDSZ = $20; // not 100% sure, maybe more
PASSPOS = $0154;
PASSSZ = $20; // not 100% sure, maybe more
begin
fh:=FileOpen(fname, fmOpenReadWrite);
if (fh> 0) then begin
try
fsz:=FileSeek(fh, 0, 2{soFromEnd});
buf:=AllocMem(fsz);
try
FileSeek(fh,0,0{soFromBeginning});
bsz:=FileRead(fh,buf^,fsz);
//change data
BufWriteData(buf,bsz,SSIDPOS,SSIDSZ,ssid);
BufWriteData(buf,bsz,PASSPOS,PASSSZ,pass);
//get crc
cnt:=bsz div 2; //word count
crc:=0;
for i := (DATASTART div 2) to cnt do begin
crc:=crc + (buf[i*2]+buf[i*2+1]*256);
end;
//update crc
//CopyMemory(PByte(buf+CRCPOS),@crc,4);
Move(crc,PByte(buf+CRCPOS)^,4);
//update file
FileSeek(fh,0,0{soFromBeginning});
if FileWrite(fh,buf^,bsz)=bsz then begin
writeln('File: '+fname);
writeln('CRC: '+IntToHex(crc));
end;
finally
freemem(buf);
end;
finally
FileClose(fh);
end;
end else raise Exception.Create('Cannot open file');
end;
var fname:string;
begin
try
if ParamStr(1)='' then begin
writeln('Usage datcrc.exe SSID password [filename]');
writeln('(filename is optional, if not defined, devParam.dat used)');
exit;
end;
fname:=paramstr(3);
if fname='' then fname:='devParam.dat';
UpdateWiFi(fname,ParamStr(1),ParamStr(2));
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
from zsgx1hacks.
Here source and binary
devParamDatCRC.zip
from zsgx1hacks.
Cool. Thanks. If you want you can add it to (C code):
https://github.com/ant-thomas/zsgx1hacks/blob/master/source/goke_p2pcam_param.c
I tried to figure out how to calculate the CRC summing up all the bytes but could not get it to work.
from zsgx1hacks.
I'm pascal developer, maybe someone with C experiences helps? It is simple (fortunately) 32 bit sum of 16bit words from 0x000c to end (size 0x0400 = 1024bytes = 512 words).
crc = word0+word1+ word2+word3+...+lastword
word0 = data[0x000c]+0x0100 * data[0x000d]
(or word0 = data[0x000c]+ data[0x000d] shl 8 )
word1 = data[0x000e]+0x0100 * data[0x000f]
....
lastword = data[0x040a]+0x0100 * data[0x040b]
CRC stored:
data[0x0004]=(crc & 0x000000ff) [lower byte of crc]
data[0x0005]=(crc & 0x0000ff00) shr 8
data[0x0006]=(crc & 0x00ff0000) shr 16
data[0x0007]=(crc & 0xff000000) shr 24 [higher byte of crc]
from zsgx1hacks.
Okay. I will add it to the C code then. Thanks for figuring that out.
from zsgx1hacks.
I got an EOutOfMemory error when running the datcrc.exe from the command line on a 32-bit Windows 7 machine. Is there an issue with the binary?
from zsgx1hacks.
I got an EOutOfMemory error when running the datcrc.exe from the command line on a 32-bit Windows 7 machine. Is there an issue with the binary?
Possibly OS returning bad file size (-1). Check the file access attributes and try it again.
from zsgx1hacks.
I created an empty file and ran the program with the file name as the third parameter and now get a message: Exception: Bad data size
from zsgx1hacks.
Briggsbfc has right. If file doesn't exists or is not specified, Exception Out of Memory is thrown.
Briggsbfc: Thank You
from zsgx1hacks.
Updated source and binary, added exception file not found
devParamDatCRC_2.zip
from zsgx1hacks.
I have a slight issue, when setting the wifi password using goke_p2pcam_param it truncates the password to the first 8 characters........
from zsgx1hacks.
Related Issues (20)
- Compiling Wireguard
- simple solution for configuring WiFi without the mobile app HOT 1
- how to rsync mp4 in sdcard to ftp server or windows share or cloud ?
- How to determine if this will work with my camera?
- Messed up /dev/mtdblock2, possible to restore from uBoot? EDIT: SOLVED! HOT 1
- Image preview URL
- Disable cam tracking
- Kevinnn25
- RTSP binary
- ZS-GX1S version hacks HOT 3
- Change the passwords and increase security
- W
- Need firmware dump
- is there a solution to able rtsp
- Can'v get any connection via rtsp or http, ZS-GQ1 HOT 1
- disable whitelight HOT 1
- GK7205/Hisilicon Hi3516E v200
- Firmware blocked HOT 1
- what do all this hosts correspond to? HOT 1
- a question
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zsgx1hacks.