Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

92
LINES

< > BotCompany Repo | #1015939 // PC Awareness [Include]

JavaX fragment (include)

1  
!include #1005410 // Cross-Platform Awareness Include
2  
3  
answer {
4  
  if "are you aware"
5  
    ret "i am aware";
6  
  if "Ping"
7  
    ret "pong";
8  
  /*if "say in english *" {
9  
    thread "Speaking" {
10  
      androidSayInEnglish(m.unq(0));
11  
    }
12  
    ret "OK";
13  
  }
14  
  if "say in english now *" {
15  
    androidSayInEnglish(m.unq(0));
16  
    ret "OK";
17  
  }*/
18  
  try answer fileOpBot(s);
19  
    
20  
  if "please eval java *"
21  
    ret "ok " + structure(evalJava($1));
22  
  if "please eval java fresh *"
23  
    ret "ok " + structure(evalJavaFresh($1));
24  
    
25  
  if "list other pcs"
26  
    ret structure(otherPCs());
27  
    
28  
  try answer awarenessBot(s);
29  
  try answer clipboardBot(s);
30  
  try answer screenshotBot(s);
31  
    
32  
  //try answer proxyBot(s);
33  
}
34  
35  
36  
37  
sbool validPeer(MachineInfo info) {
38  
  if (!info.aware || info.computerID == null) false;
39  
  if (info.lastChecked < now()-l(pinging)*pingLoopInterval*2*1000) false;
40  
  true;
41  
}
42  
43  
sS osName(MachineInfo info) {
44  
  ret contains(info.bots, "Dex Bot.") ? "Android" : info.os;
45  
}
46  
47  
svoid scanSubnet {
48  
  pcall {
49  
    S ip = getMyIP();
50  
    int i = ip.lastIndexOf('.');
51  
    if (i < 0) ret;
52  
    print("Scanning my subnet...");
53  
    for (int n = 1; n <= 255; n++) {
54  
      S peer = substring(ip, 0, i+1) + n;
55  
      scanPeer(peer);
56  
    }
57  
    print("Subnet scanned.");
58  
  }
59  
}
60  
61  
// 255 threads :)
62  
svoid scanSubnet_parallel {
63  
  pcall {
64  
    S ip = getMyIP();
65  
    int i = ip.lastIndexOf('.');
66  
    if (i < 0) ret;
67  
    print("Scanning my subnet really quickly...");
68  
    for (int n = 1; n <= 255; n++) {
69  
      fS peer = substring(ip, 0, i+1) + n;
70  
      S msg = "Peer Scan " + peer;
71  
      thread msg { scanPeer(peer); }
72  
    }
73  
  }
74  
}
75  
76  
svoid scanPeer(S peer) {
77  
  pcall {
78  
    if (!pinging.contains(peer)) {
79  
      //print("Trying " + peer);
80  
      if (isAware(peer))
81  
        addPeers(ll(peer));
82  
    }
83  
  }
84  
}
85  
86  
static L<S> otherPCs() {
87  
  new L<S> ips;
88  
  for (final MachineInfo info : findConcepts(MachineInfo, "me", false))
89  
    if (validPeer(info) && neq(osName(info), "Android"))
90  
      ips.add(info.ip);
91  
  ret ips;
92  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015939
Snippet name: PC Awareness [Include]
Eternal ID of this version: #1015939/4
Text MD5: 511832c73f4b2a0c786b6c0e4f244f3a
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-31 23:02:58
Source code size: 2067 bytes / 92 lines
Pitched / IR pitched: No / No
Views / Downloads: 358 / 775
Version history: 3 change(s)
Referenced in: [show references]