global security disclosure

pbs.c

pbs.c
Posted Aug 17, 1999

Proxy Bounce Scanner - Bounce a portscan off a web proxy server, a la 'FTP bounce attack'.

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

pbs.c

Change Mirror Download
/*
** pbs.c : Proxy Bounce Scanner - Bounce a portscan off an
** web proxy server, a la 'FTP bounce attack'
** Gus '98
**
** hi-5s to : Mr Darkcyde for his original idea.
** : #phuk, Ao12M, DM, DAC.
**
..
.. Problem : WWW Proxy servers may be an unrecognised source of
.. : hostile traffic.
..
.. Solution : Ensure that only authorised users may connect to the
.. : proxy server port.
..
**
**
**
*/


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <errno.h>
#include <string.h>
#include <signal.h>

int proxy_scan(char *,char *,int ,int ,int);
int openhost(struct hostent *, int);
int usage(char *);
void handle_alarm(int signum);


int main(int argc, char *argv[]) {
int proxy_port = 8080;
int start_port = 20;
int end_port = 24;
char *target = NULL;
char *proxy = NULL;


if (argc < 6) exit(usage(argv[0]));

proxy = argv[1];
proxy_port = atoi(argv[2]);
target = argv[3];
start_port = atoi(argv[4]);
end_port = atoi(argv[5]);


exit(proxy_scan(target,proxy,proxy_port,start_port,end_port));
}

int usage(char *name) {
fprintf(stderr,"pbs.c - Gus'98\n");
fprintf(stderr,"Usage: %s <proxy host> <proxy port>",name);
fprintf(stderr," <target> <start> <end>\n");
return(1);
}

void handle_alarm(int signum) {
alarm(0);
signal(SIGALRM, SIG_DFL);
}


int openhost(struct hostent *he, int port) {
int sock;
struct sockaddr_in sa;

memcpy(&sa.sin_addr, he->h_addr, he->h_length);

sa.sin_port=htons(port);
sa.sin_family=AF_INET;
sock=socket(AF_INET,SOCK_STREAM,0);
if (sock < 0) {
perror ("cannot open socket");
exit(-1);
}
bzero(&sa.sin_zero,sizeof (sa.sin_zero));

if (connect(sock,(struct sockaddr *)&sa,sizeof sa)<0) {
perror("Could not connect to host");
exit(-1);
}

return(sock);
}




int proxy_scan(char *target,char *proxy,int p_port,int s_port,int e_port) {

char reqbuff[1024];
char respbuff[255];
struct hostent *he;
int curport = 0;
int sock,nread;


he = gethostbyname(proxy);
if (he == NULL) {
perror("Bad hostname");
return (1);
}
printf ("Bouncing off of : %s\nPorts: %d to %d\n", proxy,s_port,e_port);


for (curport = s_port; curport <= e_port ; curport++) {
sock = openhost(he,p_port);
printf ("Trying %d...",curport);
bzero(reqbuff,sizeof(char));
sprintf(reqbuff,"GET http://%s:%d HTTP/1.0\n\n", target,curport);
write(sock,reqbuff,strlen(reqbuff));
siginterrupt(SIGALRM, 1);
signal(SIGALRM, handle_alarm);
alarm(5);
nread = read(sock,respbuff,255);
if (nread <= 0) {
if (errno == EINTR) errno = ETIMEDOUT;
printf("timeout, probably open\n");
} else {
if (strstr(respbuff," 500 ")) printf("closed.\n");
if (strstr(respbuff," 200 ")) printf("open.\n");
}
alarm(0);

(void)shutdown(sock,2);
}
printf ("\nAll done.\n");
return 0;
}
/*
** pbs.c : Proxy Bounce Scanner - Bounce a portscan off an
** web proxy server, a la 'FTP bounce attack'
** Gus '98
**
** hi-5s to : Mr Darkcyde for his original idea.
** : #phuk, Ao12M, DM, DAC.
**
..
.. Problem : WWW Proxy servers may be an unrecognised source of
.. : hostile traffic.
..
.. Solution : Ensure that only authorised users may connect to the
.. : proxy server port.
..
**
**
**
*/


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <errno.h>
#include <string.h>
#include <signal.h>

int proxy_scan(char *,char *,int ,int ,int);
int openhost(struct hostent *, int);
int usage(char *);
void handle_alarm(int signum);


int main(int argc, char *argv[]) {
int proxy_port = 8080;
int start_port = 20;
int end_port = 24;
char *target = NULL;
char *proxy = NULL;


if (argc < 6) exit(usage(argv[0]));

proxy = argv[1];
proxy_port = atoi(argv[2]);
target = argv[3];
start_port = atoi(argv[4]);
end_port = atoi(argv[5]);


exit(proxy_scan(target,proxy,proxy_port,start_port,end_port));
}

int usage(char *name) {
fprintf(stderr,"pbs.c - Gus'98\n");
fprintf(stderr,"Usage: %s <proxy host> <proxy port>",name);
fprintf(stderr," <target> <start> <end>\n");
return(1);
}

void handle_alarm(int signum) {
alarm(0);
signal(SIGALRM, SIG_DFL);
}


int openhost(struct hostent *he, int port) {
int sock;
struct sockaddr_in sa;

memcpy(&sa.sin_addr, he->h_addr, he->h_length);

sa.sin_port=htons(port);
sa.sin_family=AF_INET;
sock=socket(AF_INET,SOCK_STREAM,0);
if (sock < 0) {
perror ("cannot open socket");
exit(-1);
}
bzero(&sa.sin_zero,sizeof (sa.sin_zero));

if (connect(sock,(struct sockaddr *)&sa,sizeof sa)<0) {
perror("Could not connect to host");
exit(-1);
}

return(sock);
}




int proxy_scan(char *target,char *proxy,int p_port,int s_port,int e_port) {

char reqbuff[1024];
char respbuff[255];
struct hostent *he;
int curport = 0;
int sock,nread;


he = gethostbyname(proxy);
if (he == NULL) {
perror("Bad hostname");
return (1);
}
printf ("Bouncing off of : %s\nPorts: %d to %d\n", proxy,s_port,e_port);


for (curport = s_port; curport <= e_port ; curport++) {
sock = openhost(he,p_port);
printf ("Trying %d...",curport);
bzero(reqbuff,sizeof(char));
sprintf(reqbuff,"GET http://%s:%d HTTP/1.0\n\n", target,curport);
write(sock,reqbuff,strlen(reqbuff));
siginterrupt(SIGALRM, 1);
signal(SIGALRM, handle_alarm);
alarm(5);
nread = read(sock,respbuff,255);
if (nread <= 0) {
if (errno == EINTR) errno = ETIMEDOUT;
printf("timeout, probably open\n");
} else {
if (strstr(respbuff," 500 ")) printf("closed.\n");
if (strstr(respbuff," 200 ")) printf("open.\n");
}
alarm(0);

(void)shutdown(sock,2);
}
printf ("\nAll done.\n");
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:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close