what you don't know can hurt you

Thrip Port Scanner

Thrip Port Scanner
Posted Aug 4, 2012
Authored by grell64

This is a multithreaded scanner that scans many ip addresses on a specified port simultaneously. It is very useful for finding insecure systems when used with such ports as 23 (Telnet) or 8080, which is the web interface for many routers. The author of this program takes no responsibility for the actions of its users.

tags | tool, web, scanner
systems | unix
MD5 | c9d3910b5122fe2dcffd2717464ec816

Thrip Port Scanner

Change Mirror Download
/* 
Compile with: gcc thrip.c -o thrip -pthread

This is a multithreaded scanner that scans many ip addresses on a specified port simultaneously. It is very useful for finding insecure systems when used with such ports as 23 (Telnet) or 8080, which is the web interface for many routers. The author of this program takes no responsiblity for the actions of its users. If you have any comments or suggestions, feeel free to contact me at this email: grell64@gmail.com. Thanks and enjoy.

-Grell
*/

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


void usage(char *);

void *net_thread(void *);

FILE *glob_file;

int glob_port;

static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;

static pthread_mutex_t mtx2 = PTHREAD_MUTEX_INITIALIZER;

int main(int argc, char *argv[])
{
int numthreads, rc;
long i;

srand(time(NULL));
if(argc != 4)
usage(argv[0]);

glob_port = atoi(argv[1]);
numthreads = atoi(argv[2]);
unsigned long *taskids[numthreads];
pthread_t thread_array[numthreads];

glob_file = fopen(argv[3], "w+");

// generate array of random ip addresses
for(i = 0; i <= numthreads; i++)
{
taskids[i] = (long *) malloc(sizeof(long));
*taskids[i] = i;
rc = pthread_create(&thread_array[i], NULL, net_thread, (void *) taskids[i]);
}

// wait for all threads to finish

for(i = 0; i <= numthreads; i++)
{
pthread_join(thread_array[i], NULL);
}
return 0;
}

void usage(char *progname)
{
fprintf(stderr, "Usage: %s <port> <numthread> <output file>\n", progname);
exit(1);
}

void *net_thread(void *thr_arg)
{
int sockfd, s, g;
unsigned long connip;
unsigned int a, b, c, d;
struct sockaddr_in mysock;
char str_ip[30];

connip = (rand()) * (long) (thr_arg);

// separate bytes in connip

a = (connip >> 24 & 0xFF);
b = (connip >> 16 & 0xFF);
c = (connip >> 8 & 0xFF);
d = (connip & 0xFF);

if(a == 0x7F){ //loopback
return 0;
}

s = pthread_mutex_lock(&mtx);
printf("Scanning: %d.%d.%d.%d\n", a, b, c, d);
fflush(stdout);
s = pthread_mutex_unlock(&mtx);

if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1){
perror("socket");
pthread_exit(NULL);
}

snprintf(str_ip, sizeof(str_ip), "%d.%d.%d.%d", a, b, c, d);

bzero(&mysock, sizeof(mysock));

mysock.sin_family = AF_INET;
mysock.sin_port = htons(glob_port); // short, network byte order
mysock.sin_addr.s_addr = htonl(connip);

if((connect(sockfd, (struct sockaddr *) &mysock, sizeof(mysock))) == -1){
switch(errno){
case ECONNREFUSED:
case ETIMEDOUT:
// add mutex
s = pthread_mutex_lock(&mtx);
fprintf(glob_file, "Port %d Closed on %s\n", glob_port, str_ip);
fflush(glob_file);
s = pthread_mutex_unlock(&mtx);
break;
default:
break;
}
return 0;
}
/* connection succeeds */
else{
g = pthread_mutex_lock(&mtx2);
fprintf(glob_file, "Port %d Open on %s\n", glob_port, str_ip);
fflush(glob_file);
g = pthread_mutex_unlock(&mtx2);
return 0;
}

return 0;
}

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

June 2019

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jun 1st
    1 Files
  • 2
    Jun 2nd
    2 Files
  • 3
    Jun 3rd
    19 Files
  • 4
    Jun 4th
    21 Files
  • 5
    Jun 5th
    15 Files
  • 6
    Jun 6th
    12 Files
  • 7
    Jun 7th
    11 Files
  • 8
    Jun 8th
    1 Files
  • 9
    Jun 9th
    1 Files
  • 10
    Jun 10th
    15 Files
  • 11
    Jun 11th
    15 Files
  • 12
    Jun 12th
    15 Files
  • 13
    Jun 13th
    8 Files
  • 14
    Jun 14th
    16 Files
  • 15
    Jun 15th
    2 Files
  • 16
    Jun 16th
    1 Files
  • 17
    Jun 17th
    18 Files
  • 18
    Jun 18th
    16 Files
  • 19
    Jun 19th
    0 Files
  • 20
    Jun 20th
    0 Files
  • 21
    Jun 21st
    0 Files
  • 22
    Jun 22nd
    0 Files
  • 23
    Jun 23rd
    0 Files
  • 24
    Jun 24th
    0 Files
  • 25
    Jun 25th
    0 Files
  • 26
    Jun 26th
    0 Files
  • 27
    Jun 27th
    0 Files
  • 28
    Jun 28th
    0 Files
  • 29
    Jun 29th
    0 Files
  • 30
    Jun 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2019 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close