Skip to content

Commit e843295

Browse files
committed
Update and rename EtherTypeMiner to EtherTypeMiner.py
1 parent a2f3ae6 commit e843295

File tree

2 files changed

+117
-117
lines changed

2 files changed

+117
-117
lines changed

EtherTypeMiner

Lines changed: 0 additions & 117 deletions
This file was deleted.

EtherTypeMiner.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
'''http://standards.ieee.org/develop/regauth/ethertype/eth.txt
2+
this is the etherType text file we are going to use
3+
there are 43 lines, each one has a hex number, I have to convert
4+
all those hex numbers into decimal, and then print them back to the text file
5+
6+
NO way I am going to do that by hand. simple, use python!
7+
'''
8+
9+
10+
11+
>>> f = open('/root/Desktop/project/EtherType','r')
12+
>>> lines = f.readlines()
13+
>>> lines
14+
['0x0800 \t2048 Internet Protocol version 4 (IPv4)\n', '0x0806 \t2054 Address Resolution Protocol (ARP)\n', ......
15+
16+
'''now we get the content of the file in python's tuple, the next thing we want to do is extract only the hex numbers'''
17+
18+
>>> for i in lines:
19+
... print i[:7]
20+
...
21+
0x0800
22+
0x0806
23+
0x0842
24+
0x22F3
25+
0x6003
26+
0x8035
27+
0x809B
28+
0x80F3
29+
0x8100
30+
0x8137
31+
0x8138
32+
0x8204
33+
0x86DD
34+
0x8808
35+
0x8809
36+
0x8819
37+
0x8847
38+
0x8848
39+
0x8863
40+
0x8864
41+
0x8870
42+
0x887B
43+
0x888E
44+
0x8892
45+
0x889A
46+
0x88A2
47+
0x88A4
48+
0x88A8
49+
0x88AB
50+
0x88CC
51+
0x88CD
52+
0x88E1
53+
0x88E3
54+
0x88E5
55+
0x88F7
56+
0x8902
57+
0x8906
58+
0x8914
59+
0x8915
60+
0x892F
61+
0x9000
62+
0x9100
63+
0xCAFE
64+
#the next thing we need to do is convert them into integer
65+
66+
for i in lines:
67+
... print int(str(i[:7]),16)
68+
...
69+
2048
70+
2054
71+
2114
72+
8947
73+
24579
74+
32821
75+
32923
76+
33011
77+
33024
78+
33079
79+
33080
80+
33284
81+
34525
82+
34824
83+
34825
84+
34841
85+
34887
86+
34888
87+
34915
88+
34916
89+
34928
90+
34939
91+
34958
92+
34962
93+
34970
94+
34978
95+
34980
96+
34984
97+
34987
98+
35020
99+
35021
100+
35041
101+
35043
102+
35045
103+
35063
104+
35074
105+
35078
106+
35092
107+
35093
108+
35119
109+
36864
110+
37120
111+
51966
112+
113+
#the next thing we need to do is to write this to our file, remmember in the actual code we have 'printed' the results,
114+
#in reality we have to save them to python variables to work with them, but it is a good practice to see them first
115+
#and then do the actual programming
116+
117+

0 commit comments

Comments
 (0)