• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 22 رای - 2.68 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: سورس کد Thrip Port Scanner
حالت موضوعی
#1
Thrip Port Scannerاسکنر multithreaded هست که اسکن آدرس های IP بر روی یک پورت مشخص شده به طور همزمان است. این بسیار مفید است برای پیدا کردن سیستم های ناامن زمانی که با پورت مانند 23 (شبکه راه دور) و یا 8080، است که از رابط وب برای روترهای مورد استفاده قرار می گیرد.نویسنده این برنامه هیچ مسئولیتی در قبال اقدامات کاربران آن بر عهده نمیگیرد.

منبع : www.parsicoders.com www.pxr.ir

کد:
/*
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;
}
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  سورس کد خواندن فایل تکست (سی پلاس پلاس) Amin_Mansouri 2 6,560 09-05-2017، 12:08 PM
آخرین ارسال: ehsan.bc12
  سورس کد ایجاد افکت های مورد نظر (سی پلاس پلاس) Amin_Mansouri 0 3,561 12-06-2012، 12:29 PM
آخرین ارسال: Amin_Mansouri
  سورس کد دانلودر(سی پلاس پلاس) Amin_Mansouri 0 5,066 09-17-2012، 07:08 PM
آخرین ارسال: Amin_Mansouri
  سورس های ++C Ghoghnus 6 6,971 07-12-2012، 08:46 AM
آخرین ارسال: امیر
  سورس کد اینکریپت و دیکریپت (سی) Amin_Mansouri 1 3,493 07-07-2012، 05:13 PM
آخرین ارسال: one hacker alone
  سورس کد نمایش حجم فایل مورد نظر (سی) Amin_Mansouri 0 2,844 06-16-2012، 08:32 PM
آخرین ارسال: Amin_Mansouri
  سورس کد تبدیل مگابایت به کیلوبایت (سی) Amin_Mansouri 0 4,527 06-16-2012، 08:28 PM
آخرین ارسال: Amin_Mansouri
  سورس کد خالی کردن سطل زباله سیستم عامل ( سی ) Amin_Mansouri 0 2,758 06-16-2012، 08:25 PM
آخرین ارسال: Amin_Mansouri
  سورس کد ماشین حساب (سی پلاس پلاس) Amin_Mansouri 1 4,869 06-16-2012، 08:17 PM
آخرین ارسال: Amin_Mansouri
  سورس کد مدیریت حسابداری هتل (سی پلاس پلاس) Amin_Mansouri 0 2,883 06-08-2012، 10:23 PM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 1 مهمان