EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First New
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking New
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra New

Knowledge Bank

Discussion Forums
Enigma Chat New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Enigma Zine
Downloads
Tools New

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Hakipedia: An open collaborative for all your information security needs.

The Urinal

Click Here To Vote For EG!

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site.

enigma group

enigma group

enigma group

enigma group

Enigma Group's Code Bank


Simple ASM RS232 Transmitter Code

By: mamb0  -  Date Submitted: 2009-04-02 22:27:12

  1. Assembler RS232 Data Transmitter*/
  2.  
  3.  
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #define CNTRLZ 0x1A
  7.  
  8. int main(void) {
  9.  
  10. char readmode[] = "r";
  11. char writemode[] = "w";
  12. char datafile[] = "H:\text.txt" ;
  13. char filefailed[] = "This file has failed to loadn";
  14. char comport[] = "COM1";
  15. char comfail[] = "Failed to open COMn";
  16. char startmsg[] = "CSA File Transfer Programn";
  17. int char_send;
  18.  
  19. FILE * dp;
  20. FILE * fp;
  21.  
  22. __asm {
  23.  
  24. lea eax, startmsg //load start message 'Message'
  25. push eax //
  26. call dword ptr [printf] //display start message
  27. add esp, 4 //clear stack
  28.  
  29. //*if ((fp = fopen("H:\text.txt", "r")) == NULL)*//
  30. lea eax, readmode //
  31. push eax //
  32. lea eax, datafile //load H:\text.txt
  33. push eax //
  34. call dword ptr [fopen] //read datafile H:\txt.txt
  35. add esp,8 //
  36. mov dword ptr [fp], eax //
  37. cmp dword ptr [fp], 0 //compare file point with zero
  38. jnz comport_open //Open COM1 for file transfer if file point is 0
  39.  
  40. //*printf(""This file has failed to load/n"); return 1;*//
  41.  
  42. lea eax, filefailed //
  43. push eax //
  44. call dword ptr [printf] //display 'This file has failed to load' if there is no H:\.txt.txt
  45. add esp, 4 //
  46. jmp end_of_asm_program //Jump to the end of the program
  47.  
  48. comport_open:
  49.  
  50.  
  51. //*if ((dp = fopen("COM1", "w")) == NULL) {*//
  52. //*printf("fail to open COM portn"); return 1;*//
  53.  
  54. lea eax, writemode //
  55. push eax //
  56. lea eax, comport //
  57. push eax //
  58. call dword ptr [fopen] //Open COM port 1 for file transfer
  59. add esp, 8 //
  60. mov dword ptr [dp], eax //
  61. cmp dword ptr [dp], 0 //compare destination point to 0
  62. jnz notEOF //if destination point is 0 jump to file sending sub routine
  63. lea eax, comfail //
  64. push eax //
  65. call dword ptr [printf] //Display 'Failed to open COM' if teh COM port cannot be opened
  66. add esp, 4 //
  67. jmp end_of_asm_program //
  68.  
  69.  
  70.  
  71.  
  72.  
  73. //*while ((c = fgetc(fp )) != EOF) {*//
  74. //*fputc( c, dp);*//
  75.  
  76. notEOF:
  77. mov eax, dword ptr [fp] //
  78. push eax //
  79. call dword ptr [fgetc] //send encrypted character
  80. add esp, 4 //
  81. mov char_send, eax //
  82. cmp char_send, 0FFFFFFFFh //compare current character with the end of the file
  83. Je close_file //
  84.  
  85. mov eax, dp //
  86. push eax //
  87. mov eax, char_send //
  88. xor eax, 0e4h //encrypt character by hex value '228'
  89. push eax //
  90. call dword ptr [fputc] //transfer the file to the destination
  91. add esp,8 //
  92. Jmp notEOF //
  93.  
  94. close_file: //close both the file and its transfer parameters
  95.  
  96. mov eax, dp //
  97. push eax //
  98. mov eax, 3fh //
  99. push eax //
  100. call dword ptr [fputc] //
  101. add esp, 8 //
  102.  
  103. mov eax, fp //
  104. push eax //
  105. call dword ptr [fclose] //
  106. add esp, 4 //
  107.  
  108. mov eax, dp //
  109. push eax //
  110. call dword ptr [fclose] //
  111. add esp, 4 //
  112.  
  113. end_of_asm_program:
  114. }
  115.  
  116. return 0;
  117.  
  118. }
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