@roflsec/fail2scan 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/daemon.js +24 -16
- package/package.json +1 -1
package/bin/daemon.js
CHANGED
|
@@ -5,19 +5,23 @@ const { execFile, spawn } = require('child_process');
|
|
|
5
5
|
const { promisify } = require('util');
|
|
6
6
|
const execFileP = promisify(execFile);
|
|
7
7
|
require('dotenv').config({ quiet:true})
|
|
8
|
+
|
|
8
9
|
// -------------------- IPGeolocation --------------------
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
let getGeo = async (ip) => null;
|
|
11
|
+
if(process.env.IPGEO_API_KEY){
|
|
12
|
+
const IPGeolocationAPI = require("ip-geolocation-api-javascript-sdk");
|
|
13
|
+
const GeolocationParams = require("ip-geolocation-api-javascript-sdk/GeolocationParams.js");
|
|
14
|
+
const ipGeo = new IPGeolocationAPI(`${process.env.IPGEO_API_KEY}`, true);
|
|
15
|
+
|
|
16
|
+
getGeo = (ip) => {
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
const params = new GeolocationParams();
|
|
19
|
+
params.setIPAddress(ip);
|
|
20
|
+
params.setFields("geo,time_zone,currency,asn,security");
|
|
21
|
+
ipGeo.getGeolocation((res) => resolve(res), params);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
21
25
|
|
|
22
26
|
// -------------------- CLI / CONFIG --------------------
|
|
23
27
|
const argv = process.argv.slice(2);
|
|
@@ -149,10 +153,14 @@ async function performScan(ip){
|
|
|
149
153
|
|
|
150
154
|
try{ fs.writeFileSync(path.join(outDir,'summary.json'),JSON.stringify(summary,null,2)); } catch (e) {}
|
|
151
155
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
// geo non bloquant
|
|
157
|
+
if(process.env.IPGEO_API_KEY){
|
|
158
|
+
getGeo(ip)
|
|
159
|
+
.then(geo => {
|
|
160
|
+
try{ fs.writeFileSync(path.join(outDir,'geo.json'), JSON.stringify(geo, null, 2)); } catch(e){}
|
|
161
|
+
})
|
|
162
|
+
.catch(e=>{});
|
|
163
|
+
}
|
|
156
164
|
|
|
157
165
|
try{ fs.chmodSync(outDir,0o750); } catch (e) {}
|
|
158
166
|
log('Scan written for',ip,'->',outDir);
|