hacking contest

hacking exploits security forum
hacking
compliance articles
upgrade backup exec
information security consultant

MpR
just a lil proggie I found while modding an ircd seems to work alright meh might help someone one


/*
* ============================================================
* test.c -- Basic test program for opening TCP ports
* Copyright © 2003 AngryWolf
* Email: angrywolf@flashmail.com
* ============================================================
* Compilation: gcc -o test test.c
* (or simply "make test")
* ============================================================
* Usage: test <IP> <port>
* Example: ./test 127.0.0.1 6667
* ============================================================
* Changes:
*
* 2003-03-06: Applied suggestions by SciFi
* 2003-03-06: Coded test.c
* ============================================================
*/

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <errno.h>

#define BadPtr(x) !(x) || *(x) == '\0'

extern int errno;

void Error(char *format, ...);
void Usage();

int main(int parc, char *parv[])
{
int fd;
char *ip, *port;
struct sockaddr_in serv_addr;

/* Using more readable names */

ip = parv[1];
port = parv[2];

/* We can't work without parameters */

if (BadPtr(ip) || BadPtr(port))
Usage();

/* Trying to create a socket */

fd = socket(AF_INET, SOCK_STREAM, 0);

if (fd < 0)
Error("Can't create a new socket");

/* Setting up stuff */

bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(atoi(port));
serv_addr.sin_addr.s_addr = INADDR_ANY;

/* Trying to bind */

if (bind(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
{
Error("Couldn't bind stream socket to IP %s port %s\n[%s]",
ip, port, strerror(errno));
}

printf("Test was successful\n[opened port %s on IP %s]\n",
ip, port);

close(fd);
exit(0);
}

/*
* Error(): prints an error message
* format characters are accepted too
* (like printf())
*/

void Error(char *format, ...)
{
va_list frmt;

if (format == NULL)
return;

va_start(frmt, format);
printf("Error: ");
vprintf(format, frmt);
printf("\n");
va_end(frmt);

exit(1);
}

void Usage()
{
printf("Usage: test <IP> <port>\n");
printf("Example: ./test 127.0.0.1 6667\n");
exit(1);
}
pdf
QUOTE
printf("Test was successful\n[opened port %s on IP %s]\n",


is it a ports scanner?
Pro21
QUOTE
is it a ports scanner?

It s a "port scanner" on one define port :
* Usage: test <IP> <port>
* Example: ./test 127.0.0.1 6667
Just test if the socket is open or not.
The Storm
for this u can also use scanXXX.exe or sth. like this don`t think that this is needed but good work!
MpR
Well actually if youd o flooked a lil further or tried before comentign you may have realized that its not a port scannign a port scanner looks to see if a port is open / listening / filtered etc .. this program tries to see if the port can be opened .. its good for say firewalled buisnessed and edus . had to use this on a cisco.com root the other week because I couldnt get a port to listen made a bat got it to d/l off a http: site and made the bot run it after findign a port that would successfully open and listen I sent winshell to it to listen on that port and bam I was in .. kinda a pain but meh it worked alot of ibm.com , cisco.com dell.com , etc are firewalled out the ass and hard to find ports that will open this kinda helps in those cases . but if youre looking for a broad range port scanner I bet yah can root one without luck either way so have fun
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.

 
Invision Power Board © 2001-2005 Invision Power Services, Inc.