Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Undetectable PORT SCANNER
#1
Hello.Everyone may be having a question in their mind that how to create a PORT SCANNER[undetectable].

Here;s the script which is created by me.

Hello this is a port scanner which is very difficult to detect.


*Warning = This is only for teaching purpose,PLEASE DO NOT MISUSE.I will not be responsible FOR any ISSUES from this.

Credits goes to me because I have created this.

Here is goes.

Code:
#define _FAVOR_BSD
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<sys/wait.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<netinet/in_system.h>
#include<netinet/ip.h>
#include<netinet/tcp.h>
#include<unistd.h>
#include<time.h>
#include<netdb.h>

struct viclist {
  struct in_addr victim;
struct viclist *link;
};

struct slist {
  struct in_addr spoof;
struct slist*link;
};

int
main (int argc,char*argv[])
{
int i=0;
int sock;
int on=1;
struct sockaddr_in sockstruct;
struct ip *iphead;
char evilpacket[sizeof(struct ip) + sizeof(struct tcphdr)];
int seq,ack;
FILE *victimfile;
FILE *spoofile;
char buffer[256];
struct viclist *vcur, *vfirst;
struct slist *scur, *sfirst;
bzero(evilpacket,sizeof(evilpacket));

vfirst=malloc(sizeof(struct viclist));
vcur=vfirst;
vcur->link=NULL;

sfirst=malloc(sizeof(struct viclist));
scur=sfirst;
scur->link=NULL;

if(argc<4){
printf("Usage : %s scan_type ((S)yn / (F)in") spoof_file victim_file\n" "Example : %s S spooffile victimfile\n",argv[0],argv[o]);
exit(-1);
};

if((strncmp(argv[1],"S",1)) && (strncmp(argv[1],"F",1))) {
pritnf("\nScan type not specified");
exit(-1);
}
if((spooffile=fopen((char*)argv[2],"r")) <=0 ) {
perror(fopen);
exit(-1);
} else {
while(fgets(buffer,255,spooffile)) {
if(!(inet_aton(buffer,&(scur->spoof))))
printf("Invalid address found in the victim file..ignoring\n ");

else {
scur->link=malloc(sizeof(struct list));
scur=scur->link;
scur->link=NULL;
}
};
bzero(buffer,sizeof(buffer));
};

fclose(spooffile);
scur=sfirst;
while(scur->link!=NULL) {
printf("Found Spoof host : %s\n",inet_ntoa(scur->spoof));
scur=scur->link;
};
scur=sfirst;

if((victimfile=fopen((char*)argv[3],"r")) <=0) {
perror(fopen);
exit(-1);
} else {
while(fgets{buffer,255,victimfile)) {
if(!(inet_aton(buffer,&(vcur->victim))))
printf("Invalid address found in victim file..ignoring\n");
else {
vcur->link=malloc(sizeof(struct viclist));
vcur=vcur->link;
vcur->link=NULL;
}
};
bzero(buffer,sizeof(buffer));
};
fclose(victimfile);
vcur=vfirst;
while(vcur->link!=NULL) {
printf("Found Victim host : %s \n",inet_ntao(vcur->victim));
vcur=vcur->link;
};
vcur=vfirst;
if((sock=socket(AF_INET,SOCK_RAW.IPPROTO_RAW)) <0) {
perror("socket");
exit(-1);
}
sockstruct.sin_family=AF_INET;
iphead=(structip *)evilpacket;
tcphead=(struct tcphdr*) (evilpacket+sizeof(struct ip));
iphead->ip_hl=5;
iphead->ip_v=4;
iphead->ip_len=sizeof(struct ip)+sizeof(struct tcphdr);
iphead->ip_id=htons(getpid());
iphead->ip_tl=255;
iphead->ip_p=IPPROTO_TCP;
iphead->ip_sum=0;
iphead->ip_toss=o;
iphead->ip_off=0;
tcphead->th_win=htons(512);
if(!(atrncmp(argv[1],"s",1)))
tcphead->th_flags=TH_SYN;
else
tcphead->th_flags=TH_FIN;
tcphead->th_off=0x50;

while(vcur->link!=NULL) {
iphead->ip_dst = vcur->victim;
sleep(1);
while(scur->link!=Null)
{
seq = rand() % time(NULL);
ack = rand() % time(NULL);
tcphead->ip_src=scur->spoof;
sockstruct.sin_addr=scur->spoof;
sleep(1);
for(i = 1;i<=1024;i++){
seq+=(rand() %10)+50;
ack+=(rand() %10)+50;
stand(getpid());
tcphead->th_seq=htonl(seq);
tcphead->th_ack=htonl(ack);
tcphead->th_dport=htonl(i);
sendto(sock,&evilpacket,sizeof(evilpacket),0x0,(struct sockaddr *) & sockstruct,sizeof(sockstruct));
}
scur=scur->link;
}
scur=sfirst;
vcur=vcur->link;
}
return(1);

};

Well this was one of the best scripts created by me.I have checked this script on my computer,there was no problem,but if there is any error in typing then please let me know.


-Akshay*
[Image: 2d75599e9a.png]:superman:
#2
What do I save as, what do I do to compile?

I tried saving as .c and compiling with "Microsoft Visual C++ 6.0"

I don't have much experience with C at all (none).
#3
Thanks for the script Akshay , I saved this one, quality work.
#4
The coding is a bit of a mess, nice work, none the less, though.
#5
(10-24-2009, 02:14 AM)Extasey Wrote: What do I save as, what do I do to compile?

I tried saving as .c and compiling with "Microsoft Visual C++ 6.0"

I don't have much experience with C at all (none).

rename text file as *.c use turbo c++ to open it and then run it.. it is easier than visual c++
#6
Before you Microsoft people try and compile this...Please look at this header file #include<unistd.h> which stands for unix standard
and this pre processor line #define _FAVOR_BSD which defines the code as a Unix variant
Slackware 13/ArchLinux - C/Assem/Python
#7
Sorry I had forgotten to mention that this script is designed for unix not for xp.Tomorrow I will be posting the Xp one.
@ Extasey

You can compile it in the turbo c++.You do not need any knowledge of it.

Follow the steps and you will be able to run it.


Save it in the TC folder of the C.Now rename it and name it xyz.c[That is you can have any name with the extension .c]

Now open the turbo c++ and click of the open option and locate the file you have saved right now and with that you are done.
[Image: 2d75599e9a.png]:superman:
#8
Seems interesting.
#9
@ Alpha

Thanks.
[Image: 2d75599e9a.png]:superman:
#10
Thanks for the code bro. Smile


Possibly Related Threads…
Thread Author Replies Views Last Post
  [C++] Port Scanner [SOURCE CODE] flAmingw0rm 36 13,856 04-07-2013, 07:46 PM
Last Post: TheArmyKid

Forum Jump:


Users browsing this thread: 2 Guest(s)