flat assembler
Message board for the users of flat assembler.

Index > Windows > Write out to files

Author
Thread Post new topic Reply to topic
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes 20 Jul 2022, 20:40
Can we write out data to f00000000,f00000001,0000002...f0ffffff files without file0 filename, file1 filename...handle0, handle1?
Post 20 Jul 2022, 20:40
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1043
Location: Russia
macomics 20 Jul 2022, 22:03
You can dynamically allocate memory for the file name and generate it. Write a function that will write to this file by the file name, a pointer to the buffer with the data to be written and the length of the buffer. This way you won't need to statically define a huge set of file names and set a bunch of handle variables. They (handle) will be inside the written function as a local variable, a place for which will be allocated in the stack.
Post 20 Jul 2022, 22:03
View user's profile Send private message Reply with quote
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes 25 Jul 2022, 08:00
fil1 db '000000',0
han1 dd 0

invoke createfile...
invoke WriteFile,[han1],[mem1],01000h,bwr,0

How can I write to file 000001, 000002, 000003...exactly?
Post 25 Jul 2022, 08:00
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1043
Location: Russia
macomics 25 Jul 2022, 09:35
fwrite:
push rbp
sub rsp, 32
invoke createfile, addr [fil1], ...
mov rbp, rax
invoke WriteFile,rbp,[mem1],01000h,bwr,0
invoke CloseHandle, rbp
add rsp, 32
pop rbp
retn

mov [fil1+5], '1'
call fwrite
mov [fil1+5], '2'
call fwrite
mov [fil1+5], '3'
call fwrite
...
Post 25 Jul 2022, 09:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20460
Location: In your JS exploiting you and your system
revolution 25 Jul 2022, 09:48
Make sure fil1 is in a writeable segment.
Post 25 Jul 2022, 09:48
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1043
Location: Russia
macomics 25 Jul 2022, 12:48
fwrite:
push rbp
sub rsp, 32
invoke createfile, addr [fil1], ...
mov rbp, rax
invoke WriteFile,rbp,[mem1],01000h,bwr,0
invoke CloseHandle, rbp
add rsp, 32
pop rbp
retn
...

call [IsBadWritePtr], addr [fil1], 6
test al, al
jz error
mov [fil1+5], '1'
call fwrite
mov [fil1+5], '2'
call fwrite
mov [fil1+5], '3'
call fwrite
...
Post 25 Jul 2022, 12:48
View user's profile Send private message Reply with quote
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes 26 Jul 2022, 13:42
invoke createfile, addr [fil1], ...
error
invoke createfile, fil1,..
mov [ebp],eax
invoke WriteFile,[ebp],[mem1],01000h,bwr,0

It works. ebp or han1. Thx all.
Post 26 Jul 2022, 13:42
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.