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
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom

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


Ping Sweep

By: Evil1  -  Date Submitted: 2008-05-23 07:47:45

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Net.Sockets;
  9. using System.IO;
  10. using System.Net;
  11. using System.Runtime.InteropServices;
  12.  
  13.  
  14. namespace pingsweep
  15. {
  16. public partial class Form1 : Form
  17. {
  18. //StreamWriter sw = new StreamWriter(null, "c:\output.txt");
  19. ping PING = new ping();
  20.  
  21. public Form1()
  22. {
  23. InitializeComponent();
  24.  
  25. }
  26. public UInt32 convertIPtoLong(string ip)
  27. {
  28. string[] digits;
  29. digits = ip.Split(".".ToCharArray());
  30. return Convert.ToUInt32(
  31. Convert.ToUInt32(digits[3]) * Math.Pow(2, 24) +
  32. Convert.ToUInt32(digits[2]) * Math.Pow(2, 16) +
  33. Convert.ToUInt32(digits[1]) * Math.Pow(2, 8) +
  34. Convert.ToUInt32(digits[0]));
  35. }
  36. public string describeResponse(uint code)
  37. {
  38. string Rcode = "";
  39. switch (code)
  40. {
  41. case 0: Rcode = "Success"; break;
  42. case 11001: Rcode = "Buffer too Small"; break;
  43. case 11002: Rcode = "Dest Network Not Reachable"; break;
  44. case 11003: Rcode = "Dest Host Not Reachable"; break;
  45. case 11004: Rcode = "Dest Protocol Not Reachable"; break;
  46. case 11005: Rcode = "Dest Port Not Reachable"; break;
  47. case 11006: Rcode = "No Resources Available"; break;
  48. case 11007: Rcode = "Bad Option"; break;
  49. case 11008: Rcode = "Hardware Error"; break;
  50. case 11009: Rcode = "Packet too Big"; break;
  51. case 11010: Rcode = "Rqst Timed Out"; break;
  52. case 11011: Rcode = "Bad Request"; break;
  53. case 11012: Rcode = "Bad Route"; break;
  54. case 11013: Rcode = "TTL Exprd in Transit"; break;
  55. case 11014: Rcode = "TTL Exprd Reassemb"; break;
  56. case 11015: Rcode = "Parameter Problem"; break;
  57. case 11016: Rcode = "Source Quench"; break;
  58. case 11017: Rcode = "Option too Big"; break;
  59. case 11018: Rcode = " Bad Destination"; break;
  60. case 11019: Rcode = "Address Deleted"; break;
  61. case 11020: Rcode = "Spec MTU Change"; break;
  62. case 11021: Rcode = "MTU Change"; break;
  63. case 11022: Rcode = "Unload"; break;
  64. case 11050: Rcode = "General Failure"; break;
  65. }
  66. return Rcode;
  67. }
  68.  
  69. private void btnAbout_Click(object sender, EventArgs e)
  70. {
  71. MessageBox.Show("A simple ping sweep / whois app by Evil1", "About");
  72. }
  73.  
  74. private void btnDie_Click(object sender, EventArgs e)
  75. {
  76. // void killit(); method to kill my shit for multithreading
  77. Application.Exit();
  78. }
  79.  
  80. private void btnStart_Click(object sender, EventArgs e)
  81. {
  82. uint LongIP;
  83. string buffer;
  84. UInt32 hIP;
  85. uint timeout;
  86. buffer = new StringBuilder().Append(' ', 32).ToString();
  87. LongIP = convertIPtoLong(txtStartingIP.Text);
  88.  
  89. hIP = PING.IcmpCreateFile();
  90.  
  91. PING.pIPo.TTL = 255;
  92. timeout = 2700;
  93. PING.IcmpSendEcho(hIP, LongIP, buffer,
  94. (uint)buffer.Length,
  95. ref PING.pIPo, ref PING.pIPe,
  96. (uint)Marshal.SizeOf(PING.pIPe) + 8,
  97. timeout);
  98. MessageBox.Show(describeResponse(PING.pIPe.Status));
  99.  
  100.  
  101. }
  102. }
  103. public class ping
  104. {
  105. public struct IP_OPTION_INFORMATION
  106. {
  107. public byte TTL, Tos, Flags, OptionSize;
  108. [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 128)]
  109. public string OptionsData;
  110. }
  111. public struct ICMP_ECHO_REPLY
  112. {
  113. public uint Address, Status, RoundTripTime;
  114. public ushort DataSize, Reserved;
  115. public IP_OPTION_INFORMATION Options;
  116. }
  117. [System.Runtime.InteropServices.DllImport("icmp.dll", SetLastError = true)]
  118. public static extern uint IcmpSendEcho(
  119. uint IcmpHandle,
  120. uint DestAddress,
  121. string RequestData,
  122. uint RequestSize,
  123. ref IP_OPTION_INFORMATION RequestOptns,
  124. ref ICMP_ECHO_REPLY ReplyBuffer,
  125. uint ReplySize,
  126. uint TimeOut);
  127. [System.Runtime.InteropServices.DllImport("icmp.dll", SetLastError = true)]
  128. public static extern uint IcmpCreateFile();
  129. public static IP_OPTION_INFORMATION pIPo;
  130. public static ICMP_ECHO_REPLY pIPe;
  131.  
  132.  
  133. /* internal uint IcmpCreateFile()
  134.   {
  135.   throw new Exception("Error");
  136.   }*/
  137. }
  138. }
Return to csharp category list

Who's Online

483 Guests, 101 Users
ckryptix, viper0i0, Diznablo, rabbidmind, asapong, 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, Ios, 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