t6x / reaver-wps-fork-t6x

1.7k stars 405 forks source link

don't rewrite .wpc file if session was not modified #375

Open feitoi opened 1 year ago

feitoi commented 1 year ago

To avoid rewriting the same .wpc file without having modified the session

rofl0r commented 1 year ago

what's the problem with rewriting the session file? as is, this commit is way too complex for my taste, and a lot of malloc/free going on which can lead to subtle bugs.

feitoi commented 1 year ago

Main reason is to avoid unnecessary IO on the disk. Today many routers one day is easy to complete WPS transaction, but another day, I don't even know what is going on, WPS transaction fails, usually got timeout. Every 5 attempts, no matter if WPS transaction has completed or not, is called the save_session().

as is, this commit is way too complex for my taste, and a lot of malloc/free going on which can lead to subtle bugs.

Nothing complex. The build_session_sign() is called in the restore_session() and the save_session(). The restore_session() is called only at the beginning of the program and the save_session() is called every 5 attempts and end of the program. malloc/free is necessary for C :sweat_smile:

rofl0r commented 1 year ago

Nothing complex.

well, the commit adds 51 lines for something that can (maybe) be done in 3-6. for example, how about checking return value for the function that tests a pin, and if it fails, do not advance wpc saving mechanism.

malloc/free is necessary for C 😅

not necessarily. there are other ways to manage memory, especially if it's of a fixed small size like here. i'd rather put a char[32] into the globule struct then allocating/freeing the entire time. for local use, a stack buffer (or in C lingua "automatic variable") is preferable.

feitoi commented 1 year ago

And now, has it gotten better?

rofl0r commented 1 year ago

yeah, a lot better, dont you think yourself ?

now if you could put the snprintf calls into a static void make_session_signature(char* out) both calling sites can use the same code and there's no possibility to mess it up.