-
Notifications
You must be signed in to change notification settings - Fork 0
/
gtfobinsSearch.js
213 lines (177 loc) · 6.58 KB
/
gtfobinsSearch.js
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
var wrapper = document.querySelector('#bin-search-wrapper')
// add input to page
var ele = document.createElement('textarea')
ele.id = 'myinput'
ele.style.width = '100%'
ele.style.height = '150px'
ele.onkeyup = () => updateVisibility()
wrapper.appendChild(ele)
// on myinput change .. run func
function updateVisibility() {
// get values to search for
var programs = document.querySelector('#myinput').value.split('\n').map(val => { return val.split('/').splice(-1)[0].split('.')[0] }).filter(val => { return val != ""})
// hide if not in programs
var rows = document.querySelectorAll('tr')
Array.from(rows).forEach(row => {
let row_program = row.innerText.split('\n').map(val => { return val.trim() }).filter(val => { return val != "" })[0]
/* update matched programs */
// if (programs.includes(row_program) || programs.length == 0)
if (programs.filter(val => { return val.startsWith(row_program) }).length > 0 || programs.length == 0) {
row.style.display = 'block'
if (row.querySelector('#matches') == null) {
// does not exist - create
var ele = document.createElement('td')
ele.id = 'matches'
ele.innerText = "(" + programs.filter(val => { return val.startsWith(row_program) }).join(',') + ")"
row.appendChild(ele)
} else {
row.querySelector('#matches').innerText = "(" + programs.filter(val => { return val.startsWith(row_program) }).join(',') + ")"
}
} else
row.style.display = 'none'
})
unique_binaries()
}
function unique_binaries() {
var paths = `/usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic
/usr/lib/eject/dmcrypt-get-device
/usr/lib/snapd/snap-confine
/usr/lib/openssh/ssh-keysign
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/policykit-1/polkit-agent-helper-1
/usr/bin/newuidmap
/usr/bin/passwd
/usr/bin/chsh
/usr/bin/newgrp
/usr/bin/gpasswd
/usr/bin/newgidmap
/usr/bin/pkexec
/usr/bin/traceroute6.iputils
/usr/bin/sudo
/usr/bin/at
/usr/bin/chfn
/bin/fusermount
/bin/umount
/bin/mount
/bin/ping
/bin/su
/usr/lib/vmware-tools/bin64/vmware-user-suid-wrapper
/usr/lib/vmware-tools/bin32/vmware-user-suid-wrapper
/usr/sbin/uuidd
/usr/sbin/pppd
/usr/bin/mtr
/usr/bin/sudoedit
/sbin/mount.nfs
/bin/ping6
/bin/nano
/opt/gitlab/embedded/bin/ksu
/snap/core/7270/bin/mount
/snap/core/7270/bin/ping
/snap/core/7270/bin/ping6
/snap/core/7270/bin/su
/snap/core/7270/bin/umount
/snap/core/7270/usr/bin/chfn
/snap/core/7270/usr/bin/chsh
/snap/core/7270/usr/bin/gpasswd
/snap/core/7270/usr/bin/newgrp
/snap/core/7270/usr/bin/passwd
/snap/core/7270/usr/bin/sudo
/snap/core/7270/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/snap/core/7270/usr/lib/openssh/ssh-keysign
/snap/core/7270/usr/lib/snapd/snap-confine
/snap/core/7270/usr/sbin/pppd
/snap/core/8689/bin/mount
/snap/core/8689/bin/ping
/snap/core/8689/bin/ping6
/snap/core/8689/bin/su
/snap/core/8689/bin/umount
/snap/core/8689/usr/bin/chfn
/snap/core/8689/usr/bin/chsh
/snap/core/8689/usr/bin/gpasswd
/snap/core/8689/usr/bin/newgrp
/snap/core/8689/usr/bin/passwd
/snap/core/8689/usr/bin/sudo
/snap/core/8689/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/snap/core/8689/usr/lib/openssh/ssh-keysign
/snap/core/8689/usr/lib/snapd/snap-confine
/snap/core/8689/usr/sbin/pppd
/usr/bin/mount
/usr/bin/su
/usr/bin/fusermount
/usr/bin/umount
/usr/lib/openssh/ssh-keysign
/usr/lib/vmware-tools/bin32/vmware-user-suid-wrapper
/usr/lib/vmware-tools/bin64/vmware-user-suid-wrapper
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/s-nail/s-nail-privsep
/usr/lib/eject/dmcrypt-get-device
/usr/bin/sudo
/usr/bin/newgrp
/usr/bin/chsh
/usr/bin/passwd
/usr/bin/chfn
/usr/bin/gpasswd
/usr/sbin/amservice
/usr/sbin/amcheck
/bin/mount
/bin/ping
/bin/fusermount
/bin/su
/bin/umount
/bin/ping6
/lib/dbus-1/dbus-daemon-launch-helper
/usr/bin/staprun
/usr/bin/chage
/usr/libexec/abrt-action-install-debuginfo-to-abrt-cache
/usr/sbin/usernetctl
/tmp/vmware-tools-distrib/lib/bin64/vmware-user-suid-wrapper
/tmp/vmware-tools-distrib/lib/bin32/vmware-user-suid-wrapper
/sbin/pam_timestamp_check
/sbin/unix_chkpwd
/usr/libexec/amanda/calcsize`
var common_base_paths = ['/bin/', '/usr/', '/sbin/', '/snap/']
var unique_binary_for_searchsploit = []
var binaries = paths.split('\n').map(path => { return path.split('/').splice(-1)[0].trim() })
var my_paths = document.querySelector('#myinput').value
var my_binaries = my_paths.split('\n').filter(line => { return line != '' })
var unique_binaries = my_binaries.map(bin => {
// is base common?
let isBaseUncommon = !common_base_paths.reduce((acc, base_path) => { return bin.startsWith(base_path) || acc }, false)
let isUniqueBinary = !binaries.includes(bin.split('/').splice(-1)[0].trim())
let val = ''
if (isBaseUncommon || isUniqueBinary)
val += '<span style="color:red; font-weight:bold">' + bin + '</span>'
else
val += '<span style="color: lightgrey">' + bin + '</span>'
if (isBaseUncommon)
val += ' (base is uncommon)'
if (isUniqueBinary) {
val += ' (possibly unique binary)'
unique_binary_for_searchsploit.push(bin.split('/').splice(-1)[0].trim().replaceAll('-', ' '))
}
return val
} )
// print searchsploit cmd to console
console.log(`printf '` + unique_binary_for_searchsploit.join('\\n') + `' |xargs -I{} sh -c "echo; printf 'SEARCHING: \"{}\"\n'; searchsploit {}" | grep -v "No Results"`)
if (document.getElementById('unique_binaries')) {
document.getElementById('unique_binaries').innerHTML = '<h1>Possible Unique Binaries</h1>' + unique_binaries.join('<br>') + '<br><br><h3>Searchsploit cmd to search for unique binaries:</h3>' + `printf '` + unique_binary_for_searchsploit.join('\\n') + `' |xargs -I{} sh -c "echo; printf 'SEARCHING: \\"{}\\"\\n'; searchsploit {}" | grep -v "No Results"`
} else {
var ele = document.createElement('div')
ele.id = 'unique_binaries'
ele.innerHTML = '<h1>Possible Unique Binaries</h1>' + unique_binaries.join('<br>')
document.querySelector('#bin-search-wrapper').appendChild(ele)
}
}
// color sudo
document.querySelectorAll('a').forEach(ele => {
if (ele.innerText == 'Sudo')
ele.style.backgroundColor = 'yellow'
if (ele.innerText == 'SUID')
ele.style.backgroundColor = 'lightgreen'
if (ele.innerText == 'Limited SUID')
ele.style.backgroundColor = 'orange'
})
// overload global keydown function
document.addEventListener("keydown", function (event) {
event.stopPropagation();
}, true);