Horas..!!


Archive

How to write a port scanner in C

Sensitive Directory File-1 Sensitive Directory File-2 Shell Dork Advisories and Vulnerabilities-1 Advisories and Vulnerabilities-2 Vectors in C++ Visual Basic Irc Bot Make a Basic Batch Viruses How To Hack a Website (SUPER noobified) PHP Injection - Access Server Modifying Paypal Values on Lowlevel Web's Wireless Hacking Tracking Down a Botnet File of Password Page of Network Data Various Online Devices Vulnerable Servers Error Messages File of Important Information Page of Login Portals Analyzing a Trac SPAM Attempt Knock, Knock, Knockin' on EnGarde's Door (with FWKNOP) RPM and a perl.req Heredoc Bug HowTo: Secure your Ubuntu Apache Web Server :)~~~ Automatically Report all SSH Brute Force Attacks to ISPs <-- ???? :( Website Editing from the Perl Command Line <--wooowww ...... :) SSH Tunnel; HowTo <-- great job's :D Mitigating DNS Cache Poisoning Attacks with iptables Single Packet Authorization with Port Randomization How to write a port scanner in C Server Security <-- hehehehe..... :P Xss (Cross site scripting)  PuttyHijack V1.0 - Hijack SSH/PuTTY Connections on Windows  Pass-The-Hash Toolkit v1.4 Released for Download  SIPcrack - SIP Login Dumper & Hash/Password Cracker  Angry IP Scanner - Cross Platform Port Scanner Advanced SPA with fwknop Profiling psad with Devel::DProf Connecting to Mysql - PHP <-- jo2 Free Software Mapper and Cracker Tools Bot Search by Lateral Exploit from NewOrder and SecurityVulns ru

How to write a port scanner in C


1. Introduction
2. Principle
3. Source code
4. Greets
5. Copyright

1. Introduction |
-------------+
This text acts of the production of a very simple, but in addition, condemns fast haven scanner on text basis. It is to clarify like one a haven scanner programmed. Naturally our example cannot measure nmap or SuperScan in punkto equipment, but for the beginning it is completely good:).
Thus, now I wish you much fun with the article

2. Principle of the port scanner |
---------------------------+
The principle our port scanners is appropriate in it which we tries successively with all TCP port of the target computer to connect. This folds, is open the port, i.e. a service waits on this haven for a connection.

3. Source code |
------------+

Here is the source code with the necessary explanations.
/* name: more littleScanner
* Version: 1.0
* Author: Shadowboykevin
* Usage: more littlescanner - IP - starting port- final port - idle [in ms]
* COMMENT: Around this code to compile you must install first the RPMs of the SDL library,
*


#include < sys/socket.h>
#include < signal.h>
#include < netinet/in.h>
#include < string.h>
#include < stdlib.h>
#include < unistd.h>
#include < stdio.h>
#include " SDL.h" // that is one of the mentioned libraries

int scann_normal (char *ip, haven int); // prototype of the Scan function

int Main (int argc, char *argv [])
{
char *ip;
unsigned starting haven = 0 int;
unsigned final haven = 0 int;
unsigned int idle = 0;
int i = 0;
char *tmp;
int tmp2 = 0;

// check if the NUMBERs OF of argument is valid
if (argc < 5)
{
printf (" Error: Incorrect usage. \ n");
printf (" Usage: more littlescanner - IP - starting port - final port - idle [in ms]. \ n");
return 0;
}

// check if the IP parameters is A valid IP [incomplete]
if (strlen (argv [1]) > 15)
{
printf (" Error: The IP parameter is emergency A valid IP address \ n");
return 0;
}
else
{
strcpy (IP, argv [1]);
};

// check if starting port is A valid NUMBERs
tmp = argv [2];
tmp2 = atol (tmp);
if (tmp2 < 65535 & & tmp2 > 0)
{
starting haven = tmp2;
}
else
{
printf (" Starting port is emergency A valid NUMBERs. \ n");
return 0;
}

// check if final port is A valid NUMBERs
tmp = argv [3];
tmp2 = atol (tmp);
if (tmp2 < 65535 & & tmp2 > 0 & & tmp2 > starting haven)
{
final haven = tmp2;
}
else
{
printf (" Final port is emergency A valid NUMBERs. \ n");
return 0;
}

// I suppose idle is emergency needed tons of fuel element checked
idle = atol (argv [4]);

// Startscanning
for (i = starting port; i < = final port; i++)
{
scann_normal (IP, i);
SDL_Delay (idle); // is needed here the SDL library
}
}

int scann_normal (char *ip, haven int)
{
int sockfd; // our Socketvariable
struct sockaddr_in servaddr; // our structure for the connecting information

servaddr.sin_family = AF_INET; // the Protocol family reads AF_INET
servaddr.sin_port = htons (haven); // the port of our connection
servaddr.sin_addr.s_addr = inet_addr (IP); // and finally, the most important, the IPadresse

sockfd = socket (AF_INET, SOCK_STREAM, 0); // we request a Socket of the operating system

if (connect (sockfd, (struct sockaddr *) & servaddr, sizeof (servaddr)) ! = -1) // we try to connect, wenns fold is the haven openly
printf (" Haven %i is open \ n" , haven);

CLOSE (sockfd); // of the Socket closed there UNIX not infinitely many of it has: D
}

Submitted by:  shadowboykevin