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
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra

Knowledge Bank

Discussion Forums
Exploit Database New
PasteBin New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Downloads
Tools

Code Resources

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

Pimp Us Out!

Review enigmagroup.org on alexa.com

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.

Enigma Group

Enigma Group

Enigma Group

Enigma Group

 

Affiliates



The Urinal

hackhound.org

suck-o.com

hack.org.za

flyninja.net

 

Enigma Group's Code Bank


Binary-Ascii-HEX-Plain text converter

By: Link-  -  Date Submitted: 2008-09-26 10:22:23

  1. <?php
  2. /**
  3. * Code created by Link-
  4. *
  5. * Email your questions-comments to: Link.random@gmail.com
  6. *
  7. *
  8. *
  9. * Simple and easy... Although HEX conversion is not created yet
  10. * It will be included in the next version.
  11. *
  12. * Version 1.01
  13. **/
  14. ?>
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  19. <title>Binary-ASCII-Hex-Octal Converter</title>
  20. </head>
  21.  
  22. <body>
  23.  
  24. <table border="1" width="53%" id="table1">
  25. <tr>
  26. <td colspan="3"><font face="Verdana" size="2">&#9679; Enter the code you want
  27. to convert and click calculate:</font></td>
  28. </tr>
  29. <tr>
  30. <td width="202"><font face="Verdana" size="1">Output delimiter:</font></td>
  31. <td width="357"><form action="bahoc.php?action=convert" method="post">
  32. <font size="1" face="Verdana">
  33. <input type="text" name="delimiter_box" size="34" style="border: 1px solid #000000; font-family:Verdana; font-size:8pt"></font></td>
  34. <td><font face="Verdana" size="1">[ex: , | ' ]</font></td>
  35. </tr>
  36. <tr>
  37. <td width="202">
  38. <select size="1" name="code_type" style="font-family: Verdana; font-size: 8pt; border: 1px solid #000000">
  39. <option value="CT1">Binary</option>
  40. <option value="CT2">ASCII</option>
  41. <option value="CT3">Plain Text</option>
  42. <option value="CT4">Hex</option>
  43. </select></td>
  44. <td width="357">
  45. <textarea rows="6" name="original_code" cols="42" style="border: 1px solid #000000"></textarea></td>
  46. <td>
  47. <input type="submit" value="Calculate" name="B1" style="color: #FFFFFF; font-family: Verdana; font-size: 8pt; border: 1px solid #000000; background-color: #282828"></td></form>
  48. </tr>
  49. <tr>
  50. <td colspan="3"><hr size="1"></td>
  51. </tr>
  52. <tr>
  53. <td width="202"><font face="Verdana" size="2">Converted code:</font></td>
  54. <td colspan="2">
  55. <?php
  56. //Binary conversions hex-octal-ascii-text
  57.  
  58. //Binary Validation rule
  59. function validate_binary($input) {
  60. $input = str_split($input);
  61. for ($i=0;$i<count($input);$i++) {
  62. if ($input[$i] != "1" && $input[$i] != "0" && $input[$i] != chr(32)) {
  63. return False;
  64. break;
  65. } else {
  66. continue;
  67. }
  68. }
  69. return True;
  70. }
  71. //END
  72.  
  73. //Convert binary to hex-ascii-text
  74. function binary_to_all($input, $delimiter) {
  75. if (validate_binary($input)) {
  76. //Remove spaces and other unwanted chars
  77. $input = trim($input);
  78. //explode the string into array, delimiter is a space
  79. $orig_exp = explode(" ",$input);
  80.  
  81. //recombine the string without spaces
  82. for ($i=0; $i<count($orig_exp); $i++) {
  83. $input2 .= $orig_exp[$i];
  84. }
  85.  
  86. //Split the binary code to a set of 8 bits to convert
  87. $orig_exp2 = str_split($input2, 8);
  88. for ($i=0; $i<count($orig_exp2); $i++) {
  89. $hex_string .= $delimiter . base_convert($orig_exp2[$i],2,16);
  90. $ascii_string .= $delimiter . base_convert($orig_exp2[$i],2,10);
  91. if ($orig_exp2[$i] == "00000000") {
  92. $text_string .= $delimiter . chr(32);
  93. } else {
  94. $text_string .= $delimiter . chr(base_convert($orig_exp2[$i],2,10));
  95. }
  96. }
  97. echo "HEX :: " . $hex_string . "<br>";
  98. echo "ASCII :: " . $ascii_string . "<br>";
  99. echo "Plain-Text :: " . $text_string . "<br>";
  100. }
  101. else { echo "This is an invalid binary number!"; }
  102. }
  103. //END
  104.  
  105. //Valid ASCII code doesn't contain letters, chars, etc..
  106. function validate_ascii($input) {
  107. $input = str_split($input);
  108.  
  109. for ($i=0; $i<count($input); $i++) {
  110. if (!is_numeric($input[$i]) && $input[$i] != chr(32)) {
  111. return False;
  112. } else {
  113. }
  114. }
  115. return True;
  116. }
  117. //END
  118.  
  119. //Convert ASCII to hex-binary-text
  120. function ascii_to_all($input, $delimiter) {
  121. if (validate_ascii($input)) {
  122. //Remove spaces and other unwanted chars
  123. $input = trim($input);
  124. //Explode into arrays
  125. $orig_exp = explode(" ", $input);
  126.  
  127. //Do the conversion
  128. for ($i=0; $i<count($orig_exp); $i++) {
  129. $hex_string .= $delimiter . base_convert($orig_exp[$i],10,16);
  130. //Make sure that the binary is made of 8 chars not 7!
  131. if (strlen(base_convert($orig_exp2[$i],2,10)) < 8) {
  132. $binary_string .= $delimiter . chr(48) . base_convert($orig_exp[$i],10,2);
  133. } else {
  134. $binary_string .= $delimiter . base_convert($orig_exp[$i],10,2);
  135. }
  136. $text_string .= $delimiter . chr($orig_exp[$i]);
  137. }
  138. echo "HEX :: " . $hex_string . "<br>";
  139. echo "Binary :: " . $binary_string . "<br>";
  140. echo "Plain-Text :: " . $text_string . "<br>";
  141. } else { echo "This string contains invalid characters!"; }
  142. }
  143. //END
  144.  
  145. //Convert Plain-Text to ascii-binary-hex
  146. function text_to_all($input, $delimiter) {
  147. $input = trim($input);
  148.  
  149. //Explode into arrays
  150. $orig_exp = str_split($input);
  151.  
  152. //Do the conversion
  153. for ($i=0; $i<count($orig_exp); $i++) {
  154. $ascii_string .= $delimiter . ord($orig_exp[$i]);
  155. //Again make sure every binary code is 8 chars
  156. if ($orig_exp[$i] == " ") {
  157. $binary_string .= $delimiter . "00000000";
  158. } else {
  159. if (strlen(base_convert($orig_exp[$i],2,10)) < 8) {
  160. $binary_string .= $delimiter . chr(48) . base_convert(ord($orig_exp[$i]),10,2);
  161. } else {
  162. $binary_string .= $delimiter . base_convert(ord($orig_exp[$i]),10,2);
  163. }
  164. }
  165. $hex_string .= $delimiter . base_convert(ord($orig_exp[$i]),10,16);
  166. }
  167. echo "HEX :: " . $hex_string . "<br>";
  168. echo "Binary :: " . $binary_string . "<br>";
  169. echo "ASCII :: " . $ascii_string . "<br>";
  170. }
  171. //END
  172.  
  173. //Convert HEX to ASCII-Binary-Plain text
  174. //First we validate the hex code
  175. function validate_hex($input) {
  176. $input = str_split($input);
  177.  
  178. for ($i=0; $i<count($input); $i++) {
  179. if (!is_int($input[$i]) && $input[$i] != "A" && $input[$i] != "B" && $input[$i] != "C" && $input[$i] != "D" && $input[$i] != "E" && $input[$i] != "F") {
  180. return FALSE;
  181. } else {
  182. }
  183. }
  184. return TRUE;
  185. }
  186. //END
  187.  
  188. //Now we do the conversion
  189. function hex_to_all($input, $delimiter) {
  190. echo "Not Enabled yet!";
  191. }
  192. //END
  193.  
  194. //Switch to functions according to main code type.
  195. if ($_GET["action"] == "convert") {
  196. $conversion_type = $_POST["code_type"];
  197. $conversion_code = $_POST["original_code"];
  198. $delimiter = $_POST["delimiter_box"];
  199.  
  200. switch($conversion_type) {
  201. case 'CT1':
  202. binary_to_all($conversion_code, $delimiter);
  203. case 'CT2':
  204. ascii_to_all($conversion_code, $delimiter);
  205. case 'CT3':
  206. text_to_all($conversion_code, $delimiter);
  207. case 'CT4':
  208. hex_to_all($conversion_code, $delimiter);
  209. }
  210. }
  211. //END
  212. ?></td>
  213. </tr>
  214. </table>
  215.  
  216. </body>
  217.  
  218. </html>
Return to php category list

Who Visited EnigmaGroup Today?

1512 Guests, 298 Users (193 Spiders)
ant0601, BlAd373, nmobin27, myfabregas, spartanvedicrishi, DrOptix, g3nu1n3, saraf, VireekadiaFap, obencefoozy, memoryshot, mongrel88, drag0n, Kearstin29, litbk, alexelixir, r0z4, Abhinav2107, theanonymous21, greatg, CreedoFiegree, bivaEmilltite, posthuman01, Taireegaddita, Taicadine, c_a13, hizImmoli, scifics, slchill, KELATALFTUS, kynapse, Tonyui, Hackpad, Epilioptiop, Mamorite, IodindDog, brunoriversyhn, Effomeidonize, ReottphoffBom, arktek, burgeoningneophyte, TradaGreant, SlayingDragons, Waldlyeps, Arsenal, CJ_Omaha, Ryuske, thethird3y3, todayadvila, pwnpwnlolz, NeetaexomYgom, ookami-namikaze, dot_Cipher, Unotohumsmush, SaubymorRoyab, loltyg, Ausome1, Rik, hrangel, cyber-guard, Meonkzt, mori, 31415926, optioniLele, intorerse, FlifobbyFloks, Ios, Røgue, cossyDrybrich, IvanDimitriev, havisham, KIKNWING, fitz, fleeloCycle, hackboy302, strudels, CootoDorbeeft, gymnediny, hustleman9tv, comando300, Ysri13, thatoneguy, Paran0id, whoami, Pitanteerve, Reapon, cls777, Afrika, suetekh, somebody777, floontiny, Frudopvia, jasonbourne, zombiehack640, CloverCipher, spoosh, Fraubbova, rulebreaker, dncjor, Fintyoptots, viRuleNt, NipPaineHainy, TheHarrisonW, Jamesgo, TheGanjator, psychomarine, 1421carter, tingle65, claudius, Feld Grau, Partisan, Gunslinger, gydeqqzpn, yshiau, Zaccarato, chromoSone, priovasashCor, ellisp, GothicLogic, keetone, M0rdak, UsedDeteKef, nhorton, archestraty, HatriteBeft, JC06dc5, alpha1, spg, dark_void, wakazi, mtroscheck, TheCheeseDemon, ach.n30, sahariar, hervelegeraf, Psiber_Syn, hackaday, Mod777, neompenly, pollolololo, SnoopSky, Cigmimifs, ProloG-Shaman, unicornrainbow, cheapnikeshoxog, bobsters, foofthoorgo, polemarchos, avacraft, spencerwilliams23, lotato, ryanjcrook, dollerolf, robintenboden, rospark, WexEmbet, BeefSupreme, Hessesian, whydoyoulook, cdpirate, DnA-Ender, CaNcEr, zheincnoob, Vengeance987, justforfun363, RawTeefecycle, Squissesk, aVoid, SaMTHG, neodude, Marion1p, Ops, ddxc, Klosse, khamhou, samsatHD80, PauffPubadvic, AnnaNoult, SexyCreerve, newb1, robster1977, Blizer, Dudleypagrove, Mr_KaLiMaN, FirewallPenetrator, GMo, Seasharp, mrchicken1, Zaxem, N4g4c3N, MaxMeier, Ian, sander.ashwin, Predatorc, lonely.connection, ElEnfermado, wavyd, dirkdanblue, cve916, kalak55, a1los, jell0, Exclaw, veceattainc, Muselele, Mr Pacifist, stylish007, zach, closednetwork99, soroimmuror, PlaneReaction, Wamemanytex38, DieAble, d0seN_36b, jeremy.whitson, lol, nefeolnb, Noticon, statix, anandoump, RomeoG, advilapyday, snorapa, Gkjt, autotuneuser, beanulpinee, 2142, kiklopas, door51, Pizza, deepakkumar, makler2004, M4rcy, Xargos, bdkoenig, Blavatsky, m4f10, Huasca, itsme, xu_lain, Nikhil, ChewBigRed, samxoxo, incicaMaidits, toudioria, Chidokage, Jigoku, cesecyclelm, schn1ffl3r, sam20000, learning, kentora, San Marino, Nightraven, zanydouner, FrofErrodslot, FatalEror, wheaties, akki, AlexDiru, unclejos666, override101, blink_212, uncowstientee, lilkpoigogs, Innonaenupt607, Killshot, ZheIncKnight, ActictGlync, acarseflalk, ___, trashsporn, Memartent, Zoorsornaks, z3z3, heyhey123, Ghajnm, usaliaPels, Ordeptpen, pelly, quellense, Szuba, lamb, x1rt4m, ToutousaRulty, vipervince2002, mannavard1611, BinaryShinigami, Duchdund, afgnumgt, Anatissa, darkfire1515, bennyblanco5000, Mmmett50, ToryLogsEsoff, impalwinona, Kelsfednege, ensubbrut
 
Enigma Group