This repository has been archived by the owner on May 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
TheEye.go
224 lines (187 loc) · 6.82 KB
/
TheEye.go
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
package main
import "github.com/fatih/color"
import "strings"
import "os/exec"
import "time"
import "os"
var Version string = "1.0.4"
type ARPCahce struct {
ip [255]string
mac [255]string
TableSize int
}
var CheckARPTableDuration time.Duration = 5
var CheckHostsDuration time.Duration = 15
var CheckConnectionsDuration time.Duration = 5
var Verbose bool = false
var ARP ARPCahce
func main() {
ARGS := os.Args[1:]
color.Green("Version : "+Version)
if len(ARGS) != 0 {
if ARGS[0] == "--check-arp" {
CheckARPTable(0)
os.Exit(0)
}
if ARGS[0] == "--check-host" {
CheckHosts(0)
os.Exit(0)
}
if ARGS[0] == "--check-connections" {
CheckConnections(0)
os.Exit(0)
}
}
go CheckHosts(CheckARPTableDuration)
go CheckARPTable(CheckARPTableDuration)
CheckConnections(CheckConnectionsDuration)
}
func CheckARPTable(Duration time.Duration) {
Red := color.New(color.FgRed)
BoldRed := Red.Add(color.Bold)
Yellow := color.New(color.FgYellow)
BoldYellow := Yellow.Add(color.Bold)
Green := color.New(color.FgGreen)
BoldGreen := Green.Add(color.Bold)
BoldGreen.Println("[*] ARP cache surveillance started")
if Duration == 0 {
Duration = 3
exec.Command("sh", "-c", "arp -d -a'").Run()// Clear arp table
time.Sleep(Duration*time.Second)
ARP_Table,_ := exec.Command("sh", "-c", "arp -a").Output()
TableEntries := strings.Split(string(ARP_Table), "\n")
ARP.TableSize = (len(TableEntries)-1)
for i:=0; i < ARP.TableSize; i++ {
Temp := strings.Split(TableEntries[i], "at")
ARP.ip[i] = Temp[0]
ARP.mac[i] = Temp[1]
}
if Verbose == true {
for i:=0; i < ARP.TableSize; i++ {
BoldYellow.Println("ARP Cache : "+ARP.ip[i]+" --> "+ARP.mac[i])
}
}
for j:=0; j < ARP.TableSize; j++ {
for k:=(j+1); k < ARP.TableSize; k++ {
if ARP.mac[j] == ARP.mac[k] {
BoldRed.Println("[!] ARP poisoning detected !")
BoldRed.Print("[!] Malicious ip : ")
BoldRed.Println(ARP.ip[k])
exec.Command("sh", "-c", "notify-send -u critical 'The Eye' 'ARP poisoning detected !'").Run()
exec.Command("sh", "-c", string("notify-send -u critical 'The Eye' 'Malicious ip "+ARP.ip[k]+"'")).Run()
exec.Command("sh", "-c", "espeak 'Warning, arp poisoning detected'").Run()
}
}
}
}else {
for ;; {
exec.Command("sh", "-c", "arp -d -a'").Run()// Clear arp table
time.Sleep(Duration*time.Second)
ARP_Table,_ := exec.Command("sh", "-c", "arp -a").Output()
TableEntries := strings.Split(string(ARP_Table), "\n")
ARP.TableSize = (len(TableEntries)-1)
for i:=0; i < ARP.TableSize; i++ {
Temp := strings.Split(TableEntries[i], "at")
ARP.ip[i] = Temp[0]
ARP.mac[i] = Temp[1]
}
if Verbose == true {
for i:=0; i < ARP.TableSize; i++ {
BoldYellow.Println("ARP Cache : "+ARP.ip[i]+" --> "+ARP.mac[i])
}
}
for j:=0; j < ARP.TableSize; j++ {
for k:=(j+1); k < ARP.TableSize; k++ {
if ARP.mac[j] == ARP.mac[k] && !strings.Contains(ARP.mac[j], "<incomplete>") && !strings.Contains(ARP.mac[k], "<incomplete>") {
BoldRed.Println("[!] ARP poisoning detected !")
BoldRed.Print("[!] Malicious ip : ")
BoldRed.Println(ARP.ip[k])
exec.Command("sh", "-c", "notify-send -u critical 'The Eye' 'ARP poisoning detected !'").Run()
exec.Command("sh", "-c", string("notify-send -u critical 'The Eye' 'Malicious ip "+ARP.ip[k]+"'")).Run()
exec.Command("sh", "-c", "espeak 'Warning, arp poisoning detected'").Run()
}
}
}
}
}
}
func CheckHosts(Duration time.Duration) {
Red := color.New(color.FgRed)
BoldRed := Red.Add(color.Bold)
Green := color.New(color.FgGreen)
BoldGreen := Green.Add(color.Bold)
BoldGreen.Println("[*] Host file surveillance started")
if Duration == 0 {
// Add suspicous address recognition
}else {
for ;; {
DefaultHostsFile, _ := exec.Command("sh", "-c", "cat /etc/hosts").Output()
time.Sleep(Duration*time.Second)
HostsFile,_ := exec.Command("sh", "-c", "cat /etc/hosts").Output()
if string(HostsFile) != string(DefaultHostsFile) {
BoldRed.Println("[!] Host file has been corrupted !")
exec.Command("sh", "-c", "notify-send -u critical 'The Eye' 'Host file has been corrupted !'").Run()
exec.Command("sh", "-c", "espeak 'Warning, host file has been corrupted'").Run()
}else{
if Verbose == true {
BoldGreen.Println("[+] Host file Clean")
}
}
}
}
}
func CheckConnections(Duration time.Duration) {
Red := color.New(color.FgRed)
BoldRed := Red.Add(color.Bold)
Green := color.New(color.FgGreen)
BoldGreen := Green.Add(color.Bold)
BoldGreen.Println("[*] Suspicous connection surveillance started")
if Duration == 0 {
AllConnections, _ := exec.Command("sh", "-c", "netstat -t | grep ESTABLISHED").Output()
Connections := strings.Split(string(AllConnections), "\n")
for i := 0; i < len(Connections); i++ {
if !strings.Contains(Connections[i], ":http") && !strings.Contains(Connections[i], ":https") && !strings.Contains(Connections[i], ":netbios-ssn") {
if strings.Contains(Connections[i], ":") {
Foreign := strings.Split(Connections[i], ":")
if !strings.Contains(Foreign[1], "localhost") {
DotCount := strings.Split(Foreign[1], ".")
if len(DotCount) == 4 {
BoldRed.Print("[!] Suspicous connection detected ! ----> ")
BoldRed.Println(Foreign[1])
exec.Command("sh", "-c", "notify-send -u critical 'The Eye' 'Suspicous connection detected !'").Run()
exec.Command("sh", "-c", "espeak 'Warning, suspicous connection detected'").Run()
}
}
}
}
}
}else {
for ;; {
AllConnections, _ := exec.Command("sh", "-c", "netstat -t | grep ESTABLISHED").Output()
Connections := strings.Split(string(AllConnections), "\n")
for i := 0; i < len(Connections); i++ {
if !strings.Contains(Connections[i], ":http") && !strings.Contains(Connections[i], ":https") && !strings.Contains(Connections[i], ":netbios-ssn") {
if strings.Contains(Connections[i], ":") {
Foreign := strings.Split(Connections[i], ":")
if !strings.Contains(Foreign[1], "localhost") {
DotCount := strings.Split(Foreign[1], ".")
if len(DotCount) == 4 {
BoldRed.Print("[!] Suspicous connection detected ! ----> ")
BoldRed.Println(Foreign[1])
SuspConn,_ := exec.Command("sh", "-c", string("netstat -p | grep '"+Foreign[1]+"'")).Output()
PID := strings.Split(string(SuspConn), "ESTABLISHED")
if len(PID) < 2 {
exec.Command("sh", "-c", "notify-send -u critical 'The Eye' 'Suspicous connection detected ! \nPID: ?'").Run()
}else{
exec.Command("sh", "-c", "notify-send -u critical 'The Eye' 'Suspicous connection detected ! \n"+PID[1]+"'").Run()
}
exec.Command("sh", "-c", "espeak 'Warning, suspicous connection detected'").Run()
}
}
}
}
}
time.Sleep(Duration*time.Second)
}
}
}