-
Notifications
You must be signed in to change notification settings - Fork 0
/
extrahop-F5-silverline.js
70 lines (57 loc) · 1.86 KB
/
extrahop-F5-silverline.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
//Omar Mansour
const FNET_ODS = 'F5-Silverline';
const context = 'F5-Silverline';
const path='/api/v1/ip_lists/denylist/ip_objects';
const enableResponseEvent = true;
//triggered on an HTTP request
if(event=="HTTP_REQUEST"||event=="HTTP_RESPONSE"){
var dip=Flow.server.ipaddr;
if(dip.toString()=='HTTP server IP'){
var sip=Flow.client.ipaddr;
//looks for the origin IP (x-forward-for) as incoming requests will have F5-silverline IPs as source
var originalIP=HTTP.origin;
debug("sip="+ sip +" dip="+ dip+" original ip="+ originalIP);
debug(ThreatIntel.hasIP(originalIP));
if(ThreatIntel.hasIP(originalIP)==1){
var req= {
"data": {
"list_target": "proxy",
"id": "e12f16ed-9bf2-46bf-b5ce-7dc3827adcd3",
"type": "ip_objects",
"attributes": {
"mask": "32",
"ip": "",
"duration": 0
},
"meta": {
"note": "string",
"tags": [ ]
}
}
}
let finalReq=req;
finalReq["data"]["attributes"]["ip"]=originalIP.toString();
let sendpayload = {
'path': path,
'headers': {
"Content-Type": "application/json",
"X-Authorization-Token": "API-Token",
'context': context
},
'payload': JSON.stringify(finalReq),
'enableResponseEvent': enableResponseEvent
};
debug("Create Payload is " + JSON.stringify(finalReq, null, 1));
Remote.HTTP(FNET_ODS).request('POST', sendpayload);
}
}
}
if (event === 'REMOTE_RESPONSE') {
if (!Remote.response) {
return;
}
var responseObject = Remote.response;
var buffer = responseObject.body;
var headers = responseObject.headers;
log ('responseObject = '+responseObject.statusCode+', '+JSON.stringify(headers,null,'\t'));
}