48 lines
1.1 KiB
C
48 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <sys/socket.h>
|
|
#include <unistd.h>
|
|
#include <netdb.h>
|
|
#include <string.h>
|
|
#include "socks5.h"
|
|
#include "tor_os.h"
|
|
|
|
int main(int argc, char** argv) {
|
|
printf("~ Donar ~\n");
|
|
int sock;
|
|
|
|
struct tor_os_str tos;
|
|
tor_os_create (&tos, 10);
|
|
tor_os_read (&tos, "onion_services.txt");
|
|
tor_os_free (&tos);
|
|
|
|
if (argc < 3) {
|
|
fprintf(stderr, "Insufficient arguments\n");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
sock = create_tcp_client(argv[1], argv[2]);
|
|
socks5_handshake(sock);
|
|
socks5_connect_dns(sock, "monip.org", 80);
|
|
socks5_reply(sock);
|
|
|
|
char* req = "GET / HTTP/1.0\r\nHost: monip.org\r\n\r\n";
|
|
size_t req_len = strlen(req);
|
|
if (req_len != write(sock, req, req_len)) {
|
|
fprintf(stderr, "partial/failed write\n");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
char page[256];
|
|
size_t nread = 0;
|
|
while ((nread = read(sock, page, sizeof(char) * 255)) > 0) {
|
|
//printf("%s\n", nread);
|
|
fwrite(page, nread, 1, stdout);
|
|
}
|
|
|
|
close(sock);
|
|
exit(EXIT_SUCCESS);
|
|
}
|