-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipass.js
77 lines (69 loc) · 2.02 KB
/
pipass.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
$( document ).ready(function() {
//laptop asset number
var searchAsset=null;
//initiate a heartbeat every 2 seconds
var listening = window.setInterval(pipassListen, 2000);
//load password list
var passwords = (function () {
var json = null;
$.ajax({
'async': false,
'global': false,
'url': "/passwords.json",
'dataType': "json",
'success': function (data) {
json = data;
}
});
return json;
})();
//is PiPass listening?
//change background colour of status box to indicate potential problem
function pipassListen() {
$.ajax({
type: "POST",
url: 'listen.php',
timeout: 1000,
error: function() { $('#lastStatus').css('background-color', '#dbc2bf'); },
success: function() { $('#lastStatus').css('background-color', '#c1dbbf'); }
});
}
//search for asset
$('#assetTag').on("input", function(){
searchAsset = $(this).val();
if (passwords[searchAsset] === undefined) {
$('#confirm').prop('disabled', true);
$('#confirm').prop('checked', false);
$('#assetPass').val('');
$('#assetPassGo').attr('disabled', 'disabled');
return;
} else if (passwords[searchAsset] != '') {
$('#assetPass').val(passwords[searchAsset]);
assetVal = passwords[searchAsset];
$('#confirm').prop('disabled', false);
}
});
//activate Go! button
$('#confirm').click(function(){
if( $('#confirm').prop('checked')==true ) {
$('#assetPassGo').removeAttr('disabled');
} else {
$('#assetPassGo').attr('disabled', 'disabled');
}
});
//send asset to USB inject script
$("#assetPassGo").click(function(){
if( $('#confirm').prop('checked')==true ) {
$('#lastStatus').html("");
$.post("inject.php",
{
asset: searchAsset
},
function(data,status){
var dt = new Date();
var utcDate = dt.toUTCString();
$('#lastStatus').html(utcDate + "<br />PHP: " + status + "<br />BASH: " + data);
});
}
});
});