Jump to content
aelius

Remote traceroute

Recommended Posts

Posted

O scula buna pentru a face traceroute remote utilizand route servers

rtracert.c


#include <stdio.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/timeb.h>
#include <ctype.h>

#define TCP_PORT 23

int main(int argc, char *argv[])
{
int sockfd;
int i;
struct sockaddr_in serv_addr;
char buff[32];
struct hostent *he;


if(argc != 3) {
puts("!PARM");
exit(1);
}

if(!(he = gethostbyname(argv[1]))) {
puts("Unrecognized host or address.");
exit(2);
}

if( ( sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
puts("client: can't open socket.");
exit(1);
}
bzero((char*)&serv_addr, sizeof(serv_addr)) ;
serv_addr.sin_family = AF_INET ;
memcpy(&serv_addr.sin_addr, he->h_addr, 4);
serv_addr.sin_port = htons(TCP_PORT);

if(connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr))<0) {
puts("client: can't connect to server");
exit(1);
}

write(sockfd, "traceroute ", strlen("traceroute "));
write(sockfd, argv[2], strlen(argv[2]));
write(sockfd, "\n", 1);

while (1) {
i = read(sockfd, buff, 1);
if (buff[0] == '\n')
break;
}

setvbuf(stdout, NULL, _IONBF, 0);

while (read(sockfd, buff, 1)) {
putchar(buff[0]);
if (buff[0] == '>')
break;
}

while (read(sockfd, buff, 1)) {
putchar(buff[0]);
if (buff[0] == '>')
break;
}

puts("");
close(sockfd) ;
exit(0) ;
}

Cum il utilizati ?

Exemplu utilizare (dupa compilare)


./rtracert route_server ip_address

Exemplu:


marian@pluto:~$ cc rtracert.c -o rtracert
marian@pluto:~$ ./rtracert route-server.gblx.net 8.8.8.8
******************************* WARNING *******************************

This equipment is the property of Level 3 Communications.
Unauthorized access is strictly prohibited. Any unauthorized access
or tampering with this equipment will result in civil and/or criminal
prosecution.
******************************* WARNING *******************************

route-server.phx1>traceroute 8.8.8.8

Type escape sequence to abort.
Tracing the route to google-public-dns-a.google.com (8.8.8.8)

1 ge4-12-1000M.ar6.PHX1.gblx.net (67.16.148.37) 0 msec 0 msec 0 msec
2 72.14.197.161 8 msec 12 msec
72.14.196.50 8 msec
3 216.239.46.40 [AS 15169] 48 msec 8 msec
64.233.174.238 [AS 15169] 16 msec
4 64.233.174.192 [AS 15169] [MPLS: Label 619774 Exp 4] 12 msec
64.233.174.186 [AS 15169] [MPLS: Label 326035 Exp 4] 12 msec
72.14.238.2 [AS 15169] [MPLS: Label 604348 Exp 4] 36 msec
5 72.14.239.153 [AS 15169] [MPLS: Label 477699 Exp 4] 36 msec 40 msec
72.14.239.162 [AS 15169] [MPLS: Label 418401 Exp 4] 40 msec
6 216.239.48.167 [AS 15169] 36 msec
64.233.174.131 [AS 15169] 44 msec 40 msec

Pentru mai mute route servers, cautati pe google, sunt o gramada publice.

Tool-ul nu este facut de mine. E de prin 2001.

Posted

Mai simplu:

telnet route_server

traceroute ipaddress

nytro@pwn:~$ telnet route-server.gblx.net
Trying 67.17.81.28...
Connected to loop0.route-server.phx1.gblx.net.
Escape character is '^]'.
C
******************************* WARNING *******************************

This equipment is the property of Level 3 Communications.
Unauthorized access is strictly prohibited. Any unauthorized access
or tampering with this equipment will result in civil and/or criminal
prosecution.
******************************* WARNING *******************************

route-server.phx1>traceroute 8.8.8.8

Type escape sequence to abort.
Tracing the route to google-public-dns-a.google.com (8.8.8.8)

1 ge4-12-1000M.ar6.PHX1.gblx.net (67.16.148.37) 0 msec 0 msec 0 msec
2 72.14.196.50 12 msec 8 msec 8 msec
3 216.239.46.40 [AS 15169] 12 msec
64.233.174.238 [AS 15169] 8 msec
216.239.46.40 [AS 15169] 8 msec
4 64.233.175.150 [AS 15169] [MPLS: Label 338423 Exp 4] 56 msec
72.14.238.2 [AS 15169] [MPLS: Label 671714 Exp 4] 36 msec 40 msec
5 72.14.239.159 [AS 15169] [MPLS: Label 452774 Exp 4] 36 msec
72.14.239.155 [AS 15169] [MPLS: Label 522286 Exp 4] 40 msec
72.14.239.160 [AS 15169] [MPLS: Label 518798 Exp 4] 36 msec
6 64.233.174.131 [AS 15169] 40 msec
216.239.48.167 [AS 15169] 36 msec
64.233.174.129 [AS 15169] 40 msec
7 * * *
8 google-public-dns-a.google.com (8.8.8.8) [AS 15169] 36 msec 40 msec 36 msec
route-server.phx1>quit
Connection closed by foreign host.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...