-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntelligenceX.js
More file actions
197 lines (173 loc) · 4.92 KB
/
IntelligenceX.js
File metadata and controls
197 lines (173 loc) · 4.92 KB
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
const https = require('https')
let IntelX = class {
API_URL = '2.intelx.io';
/**
* @param {string} API_KEY Setup with API-KEY.
*/
constructor(API_KEY) {
this.API_KEY = API_KEY;
}
//https://2.intelx.io/file/preview?sid=aaaa&f=0&l=8&c=1&m=1&b=pastes&k=bde22e15-a147-4816-9414-0bf9c0755644
/**
* @param {string} sid Storage Identifier.
* @param {string} TargetFormat TargetFormat.
* @param {int} LineCount Max line count.
* @param {string} Content Content Type.
* @param {string} Media Media Type.
* @param {string} bucket
[darknet.tor] Tor hidden services (.onion domains)
[darknet.i2p] I2P eepsites (.i2p domains)
[documents.public.scihub] Public documents from Sci-Hub
[dumpster] Any data potentially relevant but does not fit into any other category
[leaks.private.general] Private Data Leaks
[leaks.public.general] Public Data Leaks
[leaks.public.wikileaks] WikiLeaks, Cryptome & Snowden data
[pastes] Pastes from various pastebin sites
[web.public.de] Public Web: Germany
[web.public.kp] North Korean public websites
[web.public.ru] Public Web: Russia
[whois] Whois data
[web.public.com]
*
* @param {boolean} e HTML encoded.
*/
//Preview(sid, Content, Media, TargetFormat, bucket, e) {
// e = e ? 1 : 0;
// return new Promise((resolve, reject) => {
// const https = require('https')
// var options = {
// hostname: this.API_URL,
// port: 443,
// path: `/file/preview?sid=${sid}&f=${TargetFormat}&l=${LineCount}&c=${Content}&m=${Media}&b=${bucket}&k=${API_KEY}`,
// method: 'GET',
// headers: {
// 'x-key': this.API_KEY
// }
// }
// const request = https.request(options, response => {
// response.on('data', d => {
// var json = JSON.parse(String(d))
// switch(json.status){
// case 0:
// //Success, search ID is valid
// resolve(String(d))
// break;
// case 1:
// reject(new Error("No future results available, stop trying. All results were delivered and the search is terminated.Note: Records may be returned with this status code."))
// break;
// case 2:
// reject(new Error("Search ID not found"))
// break;
// case 2:
// reject(new Error("No results yet available but keep trying."))
// break;
// default:
// reject(new Error("Unknown error"))
// break;
// }
// })
// })
//
// request.on('error', error => {
// reject(new Error(error))
// })
// request.end()
// })
//}
/**
* @param {string} id Get search data from id.
* @param {int} limit Max limit of results.
* @param {int} previewlines parameter can be used when later calls to /file/preview are intended in order to use the HTTP/2 Push mechanism.
*/
GetResult(id, limit, previewlines) {
return new Promise((resolve, reject) => {
const https = require('https')
var options = {
hostname: this.API_URL,
port: 443,
path: `/intelligent/search/result?id=${id}&limit=${limit}&previewlines=${previewlines}`,
method: 'GET',
headers: {
'x-key': this.API_KEY
}
}
const request = https.request(options, response => {
response.on('data', d => {
console.log(String(d))
var json = JSON.parse(String(d))
switch(json.status){
case 0:
//Success, search ID is valid
resolve(json)
break;
case 1:
reject(new Error("No future results available, stop trying. All results were delivered and the search is terminated.Note: Records may be returned with this status code."))
break;
case 2:
reject(new Error("Search ID not found"))
break;
case 2:
reject(new Error("No results yet available but keep trying."))
break;
default:
reject(new Error("Unknown error"))
break;
}
})
})
request.on('error', error => {
reject(new Error(error))
})
request.end()
})
}
/**
* @param {string} query Search for query and return id.
*/
Search(query) {
return new Promise((resolve, reject) => {
var data = JSON.stringify({
term: query,
maxresults: 10,
media: 0,
sort: 2,
terminate: []
})
const options = {
hostname: this.API_URL,
port: 443,
path: '/intelligent/search',
method: 'POST',
headers: {
'x-key': this.API_KEY
}
}
const request = https.request(options, response => {
response.on('data', d => {
var json = JSON.parse(String(d))
switch(json.status){
case 0:
this.GetResult(json.id) //resolve(json)
break;
case 1:
reject(new Error("Invalid search term"))
break;
case 2:
reject(new Error("Error, max concurrent searches per API key"))
break;
default:
reject(new Error("Unknown error"))
break;
}
})
})
request.on('error', error => {
console.log(error)
reject(err)
})
request.write(data)
request.end()
})
}
};
module.exports = IntelX