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
|
#! /usr/bin/env python3
import sys
if len(sys.argv) < 2:
print(f'Usage: {sys.argv[0]} <IP>')
sys.exit(1)
arg = sys.argv[1]
# Invalid characters on Windows: \/:*?"<>|
#edge_chars = ['¥','£','€','¢']
#chars = ['¡', '"', '#', '$', '%', '&', "'", '(', ')', ',', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '—', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '}', '~']
#chars.extend(edge_chars)
#shift_up = '+'
#shift_down = '-'
#
#c_struct = 'static char addr_char_map[] = { '
#for i in range(0, 87):
# c_struct += f'[\'{chars[i] if chars[i] != '\'' else '\\\''}\'] = {str(i)}'
# if i != 86:
# c_struct += ', '
#c_struct += ' };'
#
#s = ''
#for n in arg.split('.'):
# i = int(n, 10)
# if i >= 174:
# i -= 174
# s += shift_down
# if i >= 87:
# i -= 87
# else:
# s += shift_up
# s += chars[i]
s = ''
for n in arg.split('.'):
s += '%02x' % int(n, 10)
print(s)
|