-
Notifications
You must be signed in to change notification settings - Fork 46
/
ip.c
133 lines (122 loc) · 3.71 KB
/
ip.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/*
* License:
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
* Author: Osanda Malith Jayathissa
* Website: http://osandamalith.com
*/
void banner() {
fflush(stdin);
const static char *banner =
"\t\t\t---------------------------------\n"
"\t\t\t Welcome to IP Obfuscator \n"
"\t\t\t Coded by @OsandaMalith \n"
"\t\t\thttp://osandamalith.wordpress.com\n"
"\t\t\t---------------------------------\n";
for(banner; *banner; ++banner) fprintf(stdout, "%c", *banner);
}
int isValidIp(char *str) {
int segs = 0;
int chcnt = 0;
int accum = 0;
if (!str) return 0;
while (*str) {
if (*str == '.') {
if (!chcnt) return 0;
if (++segs == 4) return 0;
chcnt = accum = 0;
str++;
continue;
}
if ((*str < '0') || (*str > '9')) return 0;
if ((accum = accum * 10 + *str - '0') > 255) return 0;
chcnt++;
str++;
}
if (segs != 3) return 0;
if (!chcnt) return 0;
return 1;
}
int main(){
banner();
size_t i;
char ip[100], *token;
unsigned int dec[3];
const char deli[2] = ".";
const char *http = "[+] http://";
printf("\n[+] Enter your IP: ");
fgets(ip, sizeof(ip), stdin);
strtok(ip, "\n");
if(!isValidIp(ip)) {
fprintf(stderr,"%s","[!] Enter a valid ip\n");
exit(-1);
}
token = strtok(ip, deli);
for(i=0; token; i++){
*(dec+i) = atoi(token);
token = strtok(NULL, deli);
}
puts("\n[~] Obfuscated IPs :\n");
printf("[+] http://%u\n\n",(*dec << 24)|(*(dec+1) << 16)|(*(dec+2) << 8)|*(dec+3));
printf("%s", http);
for(i=0;i<4;i++) printf( i == 3 ? "0x%02X\n" : "0x%02X.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++) printf( i == 3 ? "%04o\n" : "%04o.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++) printf( i == 3 ? "0x%010X\n" : "0x%010X.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++) printf( i == 3 ? "%010o\n\n" : "%010o.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++) printf( i == 3 ? "%i\n" :"0x%02X.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++)
printf( i >= 2 ? i == 3 ? "%i\n" : "%i." : "0x%02X.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++)
printf( i >= 1 ? i == 3 ? "%i\n\n" : "%i." : "0x%02X.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++) printf( i == 3 ? "%i\n" :"%04o.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++)
printf( i >= 2 ? i == 3 ? "%i\n" : "%i." : "%04o.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++)
printf( i >= 1 ? i == 3 ? "%i\n\n" : "%i." : "%04o.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++)
if(i < 2) printf("0x%02X.",dec[i]);
printf("%u\n", (*(dec+2) << 8)|*(dec+3));
printf("%s", http);
for(i=0;i<4;i++)
if(i < 2) printf("%04o.",dec[i]);
printf("%u\n", (*(dec+2) << 8)|*(dec+3));
printf("%s", http);
for(i=0;i<2;i++)
printf( i >= 1 ? "%04o." : "0x%02X.",dec[i]);
printf("%u\n", (*(dec+2) << 8)|*(dec+3));
printf("%s", http);
for(i=0;i<4;i++)
if(i < 1) printf("0x%02X.",dec[i]);
printf("%u\n", (*(dec+1) << 16)|(*(dec+2) << 8)|*(dec+3));
printf("%s", http);
for(i=0;i<4;i++)
if(i < 1) printf("%04o.",dec[i]);
printf("%u\n", (*(dec+1) << 16)|(*(dec+2) << 8)|*(dec+3));
printf("%s", http);
for(i=0;i<4;i++)
printf( i >= 2 ? i == 3 ? "%04o\n" : "%04o." : "0x%02X.",dec[i]);
printf("%s", http);
for(i=0;i<4;i++)
printf( i >= 1 ? i == 3 ? "%04o\n" : "%04o." : "0x%02X.",dec[i]);
printf("%s", http);
for(i=0;i<2;i++)
printf( i >= 1 ? "%04o." : "0x%02X.",dec[i]);
printf("%u\n",(*(dec+2) << 8)|*(dec+3));
#ifndef __unix__
system("pause > nul");
#endif
return 0;
}