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
485 Guests, 101 Users asapong, ckryptix, Ios, viper0i0, Diznablo, rabbidmind, Nasrudin, CollapsingWalls, mehtaparag, bitstrike, jnony, C, Nicid1, Nusquam-Redono-Sapientia, bazcrown, saifulfaizan, The End, Ultraminor, psychomarine, st3alth, themastersinner, pgmrlink, login, lionaneesh, ishkur88, mahraja, Mac, chekifr, gandalf88, Vap0r, t0ast, tantrum6226, BnE, Distorted, Psiber_Syn, Ausome1, invas10n, oldgoat, freedaysbecumei, BinaryShinigami, Rex_Mundi, Red_beard, Strobeflux, s0m3nak3dguy, Descent, teehee, machupicchu, Genetix, Anandarl, NotMyOwn, thegamerdude, Godzila, popo12341234, RedEvolution, velocity_b, myne17, teto111, aVoid, Central-Gsm, 1101, JackalReborn, InjectioN, h4lted, c0re, DisPater, markt4death, splatta, Jackowacko, saint556, Pyron2312, Azerion, howsens, white.hat.gone.bad, vazzilly, pwunkz, Inverted, QuarterCask, Infernoe11, deskata, cr4ck3rj4ck, Blizer, jasonmax, j0sh, gwenwavor, N4g4c3N, spizeyboy, Network X, Uino59, Jae Cee, ianFDK, saykov, medhaavee, zofy, demonkiller410, Stumble, SaMTHG, kishore, Raze, helasraizam, Venom1019, Jakabo |
| |
|
|
|
|
|