-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathwordlist_loader.js
98 lines (82 loc) · 4.1 KB
/
wordlist_loader.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
VERSION = "1.00"
var from_tabid = parseInt( location.hash.slice(1) ),
bg = chrome.extension.getBackgroundPage(),
current_target = bg.targets.get(from_tabid),
wordlists = []
var actions = {
edit_wordlist: function(wordlist_id) { edit_wordlist(wordlist_id); current_target.settings.dictionary.del_wordlist(wordlist_id); show_wordlists() },
del_wordlist: function(wordlist_id) { current_target.settings.dictionary.del_wordlist(wordlist_id); show_wordlists() }
}
function edit_wordlist(wordlist_id)
{
var wordlist = current_target.settings.dictionary.get_wordlist(wordlist_id)
if(! wordlist)
return
document.getElementById('users').value = ''
document.getElementById('passwords').value = ''
document.getElementById('combo').value = ''
for(var i = 0; i < wordlist.users.length; i++)
document.getElementById('users').value += wordlist.users[i] + '\n'
for(var i = 0; i < wordlist.passwords.length; i++)
document.getElementById('passwords').value += wordlist.passwords[i] + '\n'
for(var i = 0; i < wordlist.combo.length; i++)
document.getElementById('combo').value += wordlist.combo[i][0] + ':' + wordlist.combo[i][1] + '\n'
}
function show_wordlists()
{
var content = ''
current_target.settings.dictionary.get_wordlists().forEach( function(wordlist) {
content += '<tr>'
content += (wordlist.users.length != 0) ? '<td><a action="edit_wordlist" wordlist_id="' + wordlist.id + '" href="#">' + wordlist.users.length + ' users </a><img src="img/delete.png" action="del_wordlist" wordlist_id="' + wordlist.id + '"></td>' : '<td></td>'
content += (wordlist.passwords.length != 0) ? '<td><a action="edit_wordlist" wordlist_id="' + wordlist.id + '" href="#">' + wordlist.passwords.length + ' passwords </a><img src="img/delete.png" action="del_wordlist" wordlist_id="' + wordlist.id + '"></td>' : '<td></td>'
content += (wordlist.combo.length != 0) ? '<td><a action="edit_wordlist" wordlist_id="' + wordlist.id + '" href="#">' + wordlist.combo.length + ' combo </a><img src="img/delete.png" action="del_wordlist" wordlist_id="' + wordlist.id + '"></td>' : '<td></td>'
content += '</tr>'
} )
document.getElementById('wordlists').innerHTML = content
wordlists = document.getElementsByTagName('a')
for(var i = 0; i < wordlists.length; i++)
{
wordlists[i].addEventListener( 'click', (function(callback,wordlist_id) { return function() {
callback(wordlist_id)
} } )( actions[ wordlists[i].getAttribute('action') ], parseInt( wordlists[i].getAttribute('wordlist_id') ) ) )
}
wordlists = document.getElementsByTagName('img')
for(var i = 0; i < wordlists.length; i++)
{
wordlists[i].addEventListener( 'click', (function(callback,wordlist_id) { return function() {
callback(wordlist_id)
} } )( actions[ wordlists[i].getAttribute('action') ], parseInt( wordlists[i].getAttribute('wordlist_id') ) ) )
}
}
window.onload = function() {
document.getElementById('ok').addEventListener( 'click', function() {
bg.Tabs.current_tab_id = from_tabid
window.close()
} )
document.getElementById('add').addEventListener( 'click', function() {
var users = document.getElementById('users').value.split("\n"),
passwords = document.getElementById('passwords').value.split("\n"),
combo = document.getElementById('combo').value.split("\n"),
wordlist = {
combo: [ ],
users: [ ],
passwords: [ ]
}
for(var i = 0; i < users.length; i++)
if( i != users.length-1 || users[i] )
wordlist.users.push( users[i] )
for(var i = 0; i < passwords.length; i++)
if( i != passwords.length-1 || passwords[i] )
wordlist.passwords.push( passwords[i] )
for(var i = 0; i < combo.length; i++)
if( combo[i].indexOf(':') != -1 )
wordlist.combo.push( [ combo[i].split(':')[0], combo[i].split(':').slice(1).join(':') ] )
if( wordlist.users.length != 0 || wordlist.passwords.length != 0 || wordlist.combo.length != 0 )
current_target.settings.dictionary.add_wordlist(wordlist)
show_wordlists()
document.getElementById('users').value = ''
document.getElementById('passwords').value = ''
document.getElementById('combo').value = ''
} )
show_wordlists()
}