EG Information
Training Missions
Knowledge Bank
|
|
Enigma Group's Code Bank
Simple ASM RS232 Transmitter CodeBy: mamb0 - Date Submitted: 2009-04-02 22:27:12 Assembler RS232 Data Transmitter*/ #include <stdio.h> #include <conio.h> #define CNTRLZ 0x1A int main(void) { char readmode[] = "r"; char writemode[] = "w"; char datafile[] = "H:\text.txt" ; char filefailed[] = "This file has failed to loadn"; char comport[] = "COM1"; char comfail[] = "Failed to open COMn"; char startmsg[] = "CSA File Transfer Programn"; int char_send; FILE * dp; FILE * fp; __asm { lea eax, startmsg //load start message 'Message' push eax // call dword ptr [printf] //display start message add esp, 4 //clear stack //*if ((fp = fopen("H:\text.txt", "r")) == NULL)*// lea eax, readmode // push eax // lea eax, datafile //load H:\text.txt push eax // call dword ptr [fopen] //read datafile H:\txt.txt add esp,8 // mov dword ptr [fp], eax // cmp dword ptr [fp], 0 //compare file point with zero jnz comport_open //Open COM1 for file transfer if file point is 0 //*printf(""This file has failed to load/n"); return 1;*// lea eax, filefailed // push eax // call dword ptr [printf] //display 'This file has failed to load' if there is no H:\.txt.txt add esp, 4 // jmp end_of_asm_program //Jump to the end of the program comport_open: //*if ((dp = fopen("COM1", "w")) == NULL) {*// //*printf("fail to open COM portn"); return 1;*// lea eax, writemode // push eax // lea eax, comport // push eax // call dword ptr [fopen] //Open COM port 1 for file transfer add esp, 8 // mov dword ptr [dp], eax // cmp dword ptr [dp], 0 //compare destination point to 0 jnz notEOF //if destination point is 0 jump to file sending sub routine lea eax, comfail // push eax // call dword ptr [printf] //Display 'Failed to open COM' if teh COM port cannot be opened add esp, 4 // jmp end_of_asm_program // //*while ((c = fgetc(fp )) != EOF) {*// //*fputc( c, dp);*// notEOF: mov eax, dword ptr [fp] // push eax // call dword ptr [fgetc] //send encrypted character add esp, 4 // mov char_send, eax // cmp char_send, 0FFFFFFFFh //compare current character with the end of the file Je close_file // mov eax, dp // push eax // mov eax, char_send // xor eax, 0e4h //encrypt character by hex value '228' push eax // call dword ptr [fputc] //transfer the file to the destination add esp,8 // Jmp notEOF // close_file: //close both the file and its transfer parameters mov eax, dp // push eax // mov eax, 3fh // push eax // call dword ptr [fputc] // add esp, 8 // mov eax, fp // push eax // call dword ptr [fclose] // add esp, 4 // mov eax, dp // push eax // call dword ptr [fclose] // add esp, 4 // end_of_asm_program: } return 0; }
|
| Return to
asm category list |
|
|
Who's Online
417 Guests, 95 Users blink_212, klesco, vapour, Ausome1, _InSane_, hemiptera, LordHelmet, BnE, N4g4c3N, chrbarrol, ThaKeeper, dark_void, th3punish3r, locust, c0re, iwanlearn, Anderl, ghostraider100, Ghostrider, eliking510, harsha2hack, NotMyOwn, Calumoo, MajorDeath, Rex_Mundi, sabre725, bhoang93, r!v3rTw!ggz, jarlskov, invas10n, snozzberries, Nusquam-Redono-Sapientia, data, zeth, psychomarine, yuka, DnA-Ender, 454447415244, Ultraminor, T-Metal, antibubbles, raven001, aVoid, Psiber_Syn, sirEgghead, Protagoras, niggletandco, Vahakn, Chaplin, BinaryShinigami, zoegeorgica, hacker807, Red_beard, eviscerator, TheFender, InjectioN, totalnoob, Posix, obrigadoo, cul8er, Mcasdf, teehee, Ops, Protest123, Blizer, gabel, Marian, Edika, zofy, Nasrudin, dochaley, TheRetech, j0sh, kcaz, cool.nik, Sand, SaMTHG, fawk3s, rajabaja, avalor, hettoo, mat_2010, barbseven, daandeveloper33, tommy1092, Likantrop7, sajan619, Knuppel, Distorted, Bloodmaster25, buffer, apablo, d0cketts, Y34RZ3R0, freakazoid |
| |
|
|
|
|
|