forked from milio48/serveo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserveo.c
92 lines (81 loc) · 4.53 KB
/
serveo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void clear_screen() {
system("clear");
}
void print_banner() {
printf("__________________________________________________ \n");
printf(". __ ___ __ ___ __ ___ ___ \n");
printf(". /__` |__ |__) \\ / |__ / \\ |\\ | |__ | \n");
printf(". .__/ |___ | \\ \\/ |___ \\__/ .| \\| |___ | \n");
printf(". \n");
printf("__________________________________________________ \n");
printf(". %s // serveo.net easy commander v1 \n", __FILE__);
printf("------------------------------------------------- \n");
printf(". milio48 | pescyte | IDBTE4M | javcode | zerobyte \n");
printf(". remade on c by guest24897 \n");
printf("__________________________________________________ \n");
printf(". \n");
printf(". *ssh installed required* \n");
printf("parameter : %s [http/tcp] [local port] [option] \n", __FILE__);
printf(". \n");
printf(" parameter [option] : 0 = request random port \n");
printf(" parameter [option] : change = change http subdomain forwarded \n");
printf(" parameter [option] : 4869 = custom port number to forwarding (using tcp) \n");
printf(". \n");
printf("%s http 80 0 //localhost:80 forward to public https \n", __FILE__);
printf(". \n");
printf(". \n");
printf("%s tcp 4869 0 //random tcp port forwarding \n", __FILE__);
printf("%s tcp 4869 1945 //custom tcp port forwarding \n", __FILE__);
printf(". \n");
printf("__________________________________________________ \n");
}
void execute_ssh_command(const char *command) {
printf("");
system(command);
printf("__________________________________________________ \n");
}
void run_serveo(const char *type, const char *local_port, const char *option) {
char command[256];
if (strcmp(type, "http") == 0) {
if (strcmp(option, "change") == 0) {
char hash[9];
FILE *fp = popen("echo -n $(date) | md5sum | cut -c1-8", "r");
if (fp == NULL) {
fprintf(stderr, "Failed to run command\n");
exit(1);
}
fgets(hash, sizeof(hash), fp);
pclose(fp);
hash[strcspn(hash, "\n")] = 0; // Remove newline character
snprintf(command, sizeof(command), "ssh -R 80:localhost:%s %[email protected]", local_port, hash);
} else if (atoi(option) > 1) {
snprintf(command, sizeof(command), "ssh -R %s:localhost:%s serveo.net", option, local_port);
} else {
snprintf(command, sizeof(command), "ssh -R 80:localhost:%s serveo.net", local_port);
}
execute_ssh_command(command);
}
if (strcmp(type, "tcp") == 0) {
if (atoi(option) > 1) {
snprintf(command, sizeof(command), "ssh -R %s:localhost:%s serveo.net", option, local_port);
} else {
snprintf(command, sizeof(command), "ssh -R 0:localhost:%s serveo.net", local_port);
}
execute_ssh_command(command);
}
}
int main(int argc, char *argv[]) {
if (argc != 4) {
fprintf(stderr, "Usage: %s [http/tcp] [local port] [option]\n", argv[0]);
return 1;
}
clear_screen();
print_banner();
printf("Running: %s %s %s %s\n", argv[0], argv[1], argv[2], argv[3]);
printf("__________________________________________________ \n");
run_serveo(argv[1], argv[2], argv[3]);
return 0;
}