master
Raw Download raw file
 1// ________                                                _________
 2// \________\--------___       ___         ____----------/_________/
 3//     \_______\----\\\\\\   //_ _ \\    //////-------/________/
 4//         \______\----\\|| (( ~|~ )))  ||//------/________/
 5//             \_____\---\\ ((\ = / ))) //----/_____/
 6//                  \____\--\_)))  \ _)))---/____/
 7//                        \__/  (((     (((_/
 8// ヾღ彡                   |  -)))  -  ))
 9// =================================================================
10// _t1_harvester.js
11// -----------------------------------------------------------------
12// author:  @nlight, @archangel
13// SEC LVL: 4
14// Chars:   
15// Descr:   Harvest t1 loc's in under 500 symbols
16//          Use with targets from ada.fullsec { npc: true }
17// Syntax:  _t1_harvester{t: #s.some_corp.loc }
18// =================================================================
19
20function(c, a)
21{
22    var _ = (c, p) => { c.forEach(p) }, // loop utility method
23		r = a.t.call({}), // first call to get method names
24		k = /d with ([a-z]+):/.exec(r)[1], // extract command key
25		j = /y with [a-z]+:"([a-z]+)"/.exec(r)[1], // extract special command
26		o = / \"([a-z_]*)\"/g, // extract commands
27		n = [], // list of commands
28		p = /y ([a-zA-Z_]*) an/, // password regex
29		v, // password
30		x = [], // project names
31		b = [], // results
32		q = {},
33		z = [/ject ([a-zA-Z_.]*) /, /e for ([a-z_0-9.]+)\. /, /on ([a-z()0-9_]+) pr/] // project name patterns
34	
35    while(c = o.exec(r)) {
36        n.push(c[1])
37    }
38	
39    _(n, c => { // for each command
40        q[k] = c
41        r = a.t.call(q) // run the script
42		
43        if((typeof r)[0]!="s") // if we get an array parse the individual items for projects
44            _(r, q => {
45                _(z, z => {
46                    o = z.exec(q)
47                    if(o) x.push(o[1])
48                })
49            })
50        else { // if we get a single item parse it for passwords
51            o = p.exec(r)
52            if(o) v = o[1]
53        }
54    })
55	
56    _(x, h => { // for each project
57        p = {project: h, password: v, pass: v, p: v}
58        p[k] = j
59        r = a.t.call(p) // call the script to get the npc locs
60        _(r, g => { // for each npc loc push it in the results array
61            b.push(g)
62        })
63    })
64	
65    return b
66}