EG Information
Training Missions
Knowledge Bank
|
|
Enigma Group's Code Bank
Ping SweepBy: Evil1 - Date Submitted: 2008-05-23 07:47:45 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Net.Sockets; using System.IO; using System.Net; using System.Runtime.InteropServices; namespace pingsweep { public partial class Form1 : Form { //StreamWriter sw = new StreamWriter(null, "c:\output.txt"); public Form1() { InitializeComponent(); } public UInt32 convertIPtoLong(string ip) { string[] digits; digits = ip.Split(".".ToCharArray()); return Convert.ToUInt32( Convert.ToUInt32(digits[3]) * Math.Pow(2, 24) + Convert.ToUInt32(digits[2]) * Math.Pow(2, 16) + Convert.ToUInt32(digits[1]) * Math.Pow(2, 8) + Convert.ToUInt32(digits[0])); } public string describeResponse(uint code) { string Rcode = ""; switch (code) { case 0: Rcode = "Success"; break; case 11001: Rcode = "Buffer too Small"; break; case 11002: Rcode = "Dest Network Not Reachable"; break; case 11003: Rcode = "Dest Host Not Reachable"; break; case 11004: Rcode = "Dest Protocol Not Reachable"; break; case 11005: Rcode = "Dest Port Not Reachable"; break; case 11006: Rcode = "No Resources Available"; break; case 11007: Rcode = "Bad Option"; break; case 11008: Rcode = "Hardware Error"; break; case 11009: Rcode = "Packet too Big"; break; case 11010: Rcode = "Rqst Timed Out"; break; case 11011: Rcode = "Bad Request"; break; case 11012: Rcode = "Bad Route"; break; case 11013: Rcode = "TTL Exprd in Transit"; break; case 11014: Rcode = "TTL Exprd Reassemb"; break; case 11015: Rcode = "Parameter Problem"; break; case 11016: Rcode = "Source Quench"; break; case 11017: Rcode = "Option too Big"; break; case 11018: Rcode = " Bad Destination"; break; case 11019: Rcode = "Address Deleted"; break; case 11020: Rcode = "Spec MTU Change"; break; case 11021: Rcode = "MTU Change"; break; case 11022: Rcode = "Unload"; break; case 11050: Rcode = "General Failure"; break; } return Rcode; } private void btnAbout_Click(object sender, EventArgs e) { MessageBox.Show("A simple ping sweep / whois app by Evil1", "About"); } private void btnDie_Click(object sender, EventArgs e) { // void killit(); method to kill my shit for multithreading Application.Exit(); } private void btnStart_Click(object sender, EventArgs e) { uint LongIP; string buffer; UInt32 hIP; uint timeout; buffer = new StringBuilder (). Append(' ', 32). ToString(); LongIP = convertIPtoLong(txtStartingIP.Text); hIP = PING.IcmpCreateFile(); PING.pIPo.TTL = 255; timeout = 2700; PING.IcmpSendEcho(hIP, LongIP, buffer, (uint)buffer.Length, ref PING.pIPo, ref PING.pIPe, (uint)Marshal. SizeOf(PING. pIPe) + 8, timeout); MessageBox.Show(describeResponse(PING.pIPe.Status)); } } public class ping { public struct IP_OPTION_INFORMATION { public byte TTL, Tos, Flags, OptionSize; [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 128)] public string OptionsData; } public struct ICMP_ECHO_REPLY { public uint Address, Status, RoundTripTime; public ushort DataSize, Reserved; public IP_OPTION_INFORMATION Options; } [System.Runtime.InteropServices.DllImport("icmp.dll", SetLastError = true)] public static extern uint IcmpSendEcho( uint IcmpHandle, uint DestAddress, string RequestData, uint RequestSize, ref IP_OPTION_INFORMATION RequestOptns, ref ICMP_ECHO_REPLY ReplyBuffer, uint ReplySize, uint TimeOut); [System.Runtime.InteropServices.DllImport("icmp.dll", SetLastError = true)] public static extern uint IcmpCreateFile(); public static IP_OPTION_INFORMATION pIPo; public static ICMP_ECHO_REPLY pIPe; /* internal uint IcmpCreateFile() { throw new Exception("Error"); }*/ } }
|
| 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 |
| |
|
|
|
|
|