-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathutils.gs
3239 lines (3231 loc) · 130 KB
/
utils.gs
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//////////////////////////////////////////////////////////////
///======================= UTILS ========================////
////////////////////////////////////////////////////////////
SS = get_custom_object// SEASHELL CUSTOM OBJECT
SS.version = "1.0.7a"
SS.buildv = "1.7.2a"
SS.cwd = current_path
SS.ccd = ".ss"// current cache dir, this is where seashell builds
SS.debug = null
SS.anon = false
SS.og = null
SS.training_wheels = false // 8)
TW = SS.training_wheels
SS.pastecb = false//builder
SS.o = null // current object
SS.bamrun = null// BAM runtask
SS.bamargs = []
SS.bamret = null // return?
SS.bamres = null// result?
SS.launchres = null
SS.aargs = []
SS.cb = null
SS.dbe = null
SS.dbec = 0
SS.dbh = null
SS.dbhc = 0
SS.dbhl = []
SS.dbl = null
SS.remote = false
SS.rsip = null
OGT = function; s=true;if SS.og then s=null;SS.og=s;end function;
EXIT = function(s=null);if not s then s = "Exiting...".sys return exit(s); end function;
///==================== FuncRefs ========================////
LOG = @print
INPUT = @user_input
HOME = @home_dir
T = @typeof
NL = char(10)
SP = char(32)
E = ""
COLUMNS = @format_columns
CLEAR = function; return clear_screen; end function;
///==================== Maps ========================////
SS.mutate = function
TW = SS.training_wheels
string.size = function(self, s)
if T(s) == "number" then s = str(s)
return "<size="+s+">"+self+"</size>"
end function
string.b = function(self)
return "<b>"+self+"</b>"
end function
string.i = function(self)
return "<i>"+self+"</i>"
end function
string.angle = function(n)
if T(n)!= "number" then n = n.to_int
return "<rotate="+str(n)+">"+self+"</rotate>"
end function
string.voffset = function(n)
if T(n)!= "number" then n = n.to_int
return "<voffset="+str(n)+">"+self+"</voffset>"
end function
string.pos = function(n)
if T(n)!= "number" then n = n.to_int
return "<pos="+str(n)+">"+self+"</pos>"
end function
string.s = function(self)
return self+" "
end function
string.white = function(self)
return "<#FFFFFF>" + self + "</color>"
end function
string.grey = function(self)
return "<#A5A5A5>" + self + "</color>"
end function
string.black = function(self)
return "<#000000>"+self+"</color>"
end function
string.red = function(self)
return "<#AA0000>" + self + "</color>"
end function
string.orange = function(self)
return "<#FF6E00>" + self + "</color>"
end function
string.yellow = function(self)
return "<#FBFF00>" + self + "</color>"
end function
string.green = function(self)
return "<#00ED03>" + self + "</color>"
end function
string.lgreen = function(self)
return "<#35fca6>"+self+"</color>"
end function
string.lblue = function(self)
return "<#00BDFF>" + self + "</color>"
end function
string.blue = function(self)
return "<#003AFF>" + self + "</color>"
end function
string.purple = function(self)
return "<#D700FF>" + self + "</color>"
end function
string.cyan = function(self)
return "<#00FFE7>" + self + "</color>"
end function
string.sys = function(self)
return "[<#00FFE7>SeaShell</color>] <i>" + self.white
end function
string.debug = function(self)
return "[<#00FFE7>debug</color>] <i>" +self.white
end function
string.ok = function(self)
return "[<#00ED03><b>success</b></color>] " + self.white
end function
string.warning = function(self)
return "[<#FBFF00><b>warning</b></color>] <i>" + self.grey
end function
string.error = function(self)
return "[<#AA0000><b>error</b></color>] " + self.yellow
end function
string.prompt = function(self)
return "["+"input".white.b+"]"+"-- ".white+self.grey+" --> ".white
end function
string.fill = function(self)
return "><> ><> ><> ><> ><> ><> ><> ><> ><> ><> ><> ><> ><> ><>".blue + self //+ NL
end function
string.NL = function(self)
return self+globals.NL
end function
string.strip = function(self)// forgot what this was going to be used for
if self.len < 15 then return null
self = self[:15]
return self[:self.len-8]
end function
string.bitToByte = function(self)
b = to_int(self);s=["B","KB","MB","GB"];i=0;
while b>1024
b=b/1024
i=i+1
end while
return round(b,2)+s[i]
end function
string.isRoot = function(self, u, hex = "FFFFFF")
if self == u then return self.green
//if (self == u) or (u == "root") then return self.green
if self == "root" or self == "unknown" then return self.red
if self == "guest" then return self.orange
return "<#"+hex+">"+self+"</color>"
end function
string.isSlash = function
if self == "/" then return "root".green
return self.grey
end function
string.isPc = function(self)
if get_router(self).local_ip != self then return true
return false
end function
string.isProc = function(self)
if ["Xorg","kernel_task", "dsession"].indexOf(self) != null then return self.red
if ["Terminal", "CodeEditor", "Browser", "Mail", "Settings","FileExplorer", "Notepad", "Chat", "ConfigLan", "AdminMonitor"].indexOf(self) != null then return self.green
return self.yellow
end function
string.isIp = function(self)
if not is_valid_ip(self) and not is_lan_ip(self) then return nslookup(self)
return self
end function
string.isLan = function
if is_lan_ip(self) then return self
end function
string.getGw = function(self)
if is_lan_ip(self) then return get_router.public_ip
if is_valid_ip(self) then return self
return "!Invalid!".error
end function
string.isUnknown = function(self, hex = "FFFFFF")
if self.lower == "unknown" then return self.grey
return "<#"+hex+">"+self+"</color>"
end function
string.rule = function(self, s = null)
if self == "DENY" or s == "DENY" then return self.red
if self == "ALLOW" or s == "ALLOW" then return self.green
return self.grey;
end function
string.month_int = function(self)
return to_int((["Jan", "Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",].indexOf(self))+1)
end function
string.wrap = function(self, hex = "FFFFFF", n = 20)
sl = "["+self+"]"; sl = sl.len;
if hex then s_t = "[<#"+hex+">"+self+"</color>]"
if not hex then s_t = "["+self+"]"
if sl >= n then return s_t
for i in range(1, (n-sl)); s_t = s_t+"—"; end for;
return s_t
end function
string.cap = function(self, cap, hex = "FFFFFF", ih = null)
if hex and ih then return self+"[<#"+hex+">"+cap+"</color>]"
if ih then return self+"["+cap+"]"
return self+"[<#"+hex+">"+cap+"</color>]"
end function
string.title = function(self, hex = "FFFFFF", si = 40)
sl = "["+self+"]"; sl = sl.len;
s_t = "[<#"+hex+">"+self+"</color>]"
if sl >= si then return s_t
for i in range(1, (si-sl)/2); s_t = "—"+s_t+"—"; end for;
return s_t
end function
string.fromMd5 = function(self);
if T(SS.dbh) != "file" then return self;
find = SS.MD5.find(self);
if find != null then return find;
return self;
end function;
string.isOp = function(self, v)
if self == v then return self.red
return self.white
end function
string.tiempo = function(self,a)
return self.join(a)
end function
string.stampana = function(self,a)
o=[]
for s in self.values
o.push((s.code)+a)
end for
return o
end function
string.r8 = function
if self == "file" then return self.orange
if self == "computer" then return self.yellow
if self == "shell" then return self.green
return self.grey
end function
// ======== Art from earlier versions of seashell
string.ogconnect = function(self)
if SS.og == null then return self
out = ""
out = out+" _______________ |".white+"*".red+"\_/".white+"*".red+"|________".white+NL
out = out+" | ___________ | ".white+".-. .-.".red+" ||_/-\_|______ |".white+NL
out = out+" | | | | ".white+".****. .****.".red+" | | | |".white+NL
out = out+" | | ".white+"0 0".green+" | | ".white+".*****.*****.".red+" | | ".white+"0 0".red+" | |".white+NL
out = out+" | | - | | ".white+".*********.".red+" | | - | |".white+NL
out = out+" | | \___/ | | ".white+".*******.".red+" | | \___/ | |".white+NL
out = out+" | |___ ___| | ".white+".*****.".red+" | |___________| |".white+NL
out = out+" |_____|\_/|_____| ".white+".***.".red+" |_______________|".white+NL
out = out+" _|__|/ \|_|_".white+"............".red+".*..............".red+"_|________|_".white+NL
out = out+" / ********** \ / ********** \".white+NL
out = out+" / ************ \ / ************ \".white+NL
out = out+"-------------------- --------------------".white+NL
out = out+self
self = out
return self
end function
string.ogsniff = function(self)
o=""
o = o+" __".blue+NL
o = o+" |::|".blue+NL
o = o+" |::|".blue+NL
o = o+" _..---.._ |::|".blue+NL
o = o+" .' / \ `. |::|".blue+NL
o = o+" / / \ \ |::|".blue+NL
o = o+" / / \ \ | |".blue+NL
o = o+" / | | \ | |".blue+NL
o = o+" | | ___ | | | |".blue+NL
o = o+" _`'..._-.|____|__|\\/|__|____|..| | ___".blue+NL
o = o+" ____... | .- - - - - - - -. | .| |_ `'".blue+NL
o = o+" ____. /.-----------------.\ .| | ```..".blue+NL
o = o+"``.. //' `-._ _.-` '\\ | | ..".blue+NL
o = o+" ...-' ||' /.-.\ /.-.\ '|| `..\...`'`".blue+NL
o = o+" ---._` \\:_ \(".blue+"o".red+")/...\(".blue+"o".red+")/._:// .----..---".blue+NL
o = o+" ___.._ __.... ._....._.....___".blue+NL
o = o+"'' ___.._ __.... ._....._.....___".blue+NL
o = o+self
return o
end function
string.oggotroot = function(self)
o=""
o=o+" ____".green+NL
o=o+" /\| ~~\".green+NL
o=o+" /' | ,-. `\".green+NL
o=o+" | | X | |".green+NL
o=o+" _|________`-' |X".green+NL
o=o+" /' ~~~~~~~~~,".green+NL
o=o+" /' ,_____,/_".green+NL
o=o+" ,/' ___,'~~ ;".green+NL
o=o+"~~~~~~~~|~~~~~~~|--- / X,~~~~~~~~~~~~,".green+NL
o=o+" | | | XX'____________'".green+NL
o=o+" | | /' XXX| ;".green+NL
o=o+" | | --x| XXX,~~~~~~~~~~~~,".green+NL
o=o+" | | X| '____________'".green+NL
o=o+" | o |---~~~~\__XX\ |XX".green+NL
o=o+" | | XXX`\ /XXXX".green+NL
o=o+"~~~~~~~~'~~~~~~~' `\xXXXXx/' \XXX".green+NL
o=o+" /XXXXXX\".green+NL
o=o+" /XXXXXXXXXX\".green+NL
o=o+" /XXXXXX/^\X2NAXX\".green+NL
o=o+" ~~~~~~~~ ~~~~~~~".green+NL
o = o+self
return o
end function
string.ogfishtank = function(self)
o=o+"| \|/ * . . . .. . |".blue+NL
o=o+"| \|*/* .. _ . . |".blue+NL
o=o+"| *|| | .. ><_> . _ |".blue+NL
o=o+"| |`|/ _ . <_>< |".blue+NL
o=o+"| \| ><_> _ |".blue+NL
o=o+"`-----!---------!!!---!!!---/ \--'".blue+NL
o = o+self
return o
end function
string.TW = function
if SS.training_wheels == false then return
return "SeaShell Tips".title+NL+self.grey
end function
string.a = function(self)
if SS.anon == true then return "HIDDEN".grey.size(14)
return self
end function
string.oc = function(self)
return "<mark=#00BDFF>"+self.b+"</font></mark>"
end function
string.crab = function(self)
return ("C".red.b+".".white+"R".red.b+".".white+"A".red.b+".".white+"B".red.b).s+(self.white.i)
end function
string.raft = function(self)
return ("R".red.b+".".white+"A".red.b+".".white+"F".red.b+".".white+"T".red.b).s+(self.white.i)
end function
string.asHex = function(self)
return "<font=""LiberationSans SDF""><mark=#FFFFFF>"+self.black.b+"</color></mark></font>"
end function
string.raftPic = function(self)
o=[
" "+"v".white+" ~. "+"v".white,
" "+"v".white+" /|",
" / | "+"v".white,
" "+"v".white+" /__|__",
" \--------/",
"~~~~~~~~~~~~~~~~~~~".lblue+"`"+"~~~~~~".lblue+"'"+"~~~~~~~~~~~~~~~~~~~~~~~~".lblue,
self,
]
if not SS.og then return self
return o.join(NL)
end function
string.toack = function(self)
if self.indexOf("%") != null then self = self.replace("%", "")
self = to_int(self)
self = str((300000/self))
return self
end function
string.BL = function(self)
return "|".lblue+self
end function
string.YL = function(self)
return "|".yellow+self
end function
string.RL = function(self)
return "|".red+self
end function
string.genSimpleExpSummary = function(self)
fi = SS.c.File(self)
if T(fi) != "file" then return "ERROR".red
u = []
s = []
c = []
f = []
for h in SS.EXP.format(fi.get_content)
if h.len < 1 then continue
if h[0].exploit == "Unknown" then; u.push(h); continue; end if;
if h[0].exploit == "shell" then; s.push(h); continue; end if;
if h[0].exploit == "computer" then; c.push(h); continue; end if;
if h[0].exploit == "file" then; f.push(h); continue; end if;
end for
return NL+BL+"Shells".wrap("A5A5A5",15).cap(c.len.rate).NL+BL+"Computers".wrap("A5A5A5",15).cap(u.len.rate).NL+BL+"Files".wrap("A5A5A5",15).cap(f.len.rate).NL+BL+"Unknown".wrap("A5A5A5",15).cap(u.len.rate)
end function
string.progressBar = function(self,c,t)
if t > 100 then return null
rate = ceil((t/c)*100)
if t > 10 then pct = (ceil(((c/t)*100))-1)/10 else pct = ceil(((c/t)*100))
rem = t-c
if t > 10 then rem = ceil(rem)/10 else rem = rem
wait 0.2
LOG(self.sys+" ["+("#"* pct).lblue +("-"* rem).grey+"]—["+str(pct).white+"%".grey+"]",1)
end function
// ======== LISTS
list.table = function(title)
return self
end function
list.select = function(l=null)
if l then ret = l
if l == null then ret = "[ "+"SELECT".grey+" ] "+NL
c = 1
for s in self
if c == self.len then
ret = ret + str(c).white + "."+") ".white+s
else
ret = ret + str(c).white + "."+") ".white+s+NL
end if
c = c+1
end for
ret = ret//+"-- Press 0 to return --> ".grey
return ret
end function
list.select_w_count = function(self, l)
ret = "[ "+"SELECT".grey+" ] "+NL
c = 1
for i in range(0, l.len-1)
ret = ret + str(c).white + "."+") ".white+self[i]+" "+l[i] +NL
end for
end function
list.select2 = function()
ret = "";c=1
for s in self
ret = ret + str(c).white + "."+") ".white+s+NL
c = c+1
end for
ret = ret + "0".white+"."+") ".white+"Exploit the router".orange.b+NL
ret = ret+NL+"Select".prompt
return ret
end function
list.oddOne = function(self,l2)
for item in l2
if self.indexOf(item) == null then return item
end for
return null
end function
number.rate = function(self)
if self < 3 then return str(self).green
if self > 3 and self < 10 then return str(self).yellow
return str(self).red
end function
// end of mutation
end function
SS.mutate// to be reused in sf
BL = "|".lblue
YL = "|".yellow
RL = "|".red
///======================== UTIL =========================////
SS.Utils = {}
SS.Utils.ds = function(o, type = "computer")
types = [{"t": "shell", "v": 3}, {"t": "ftpshell", "v": 3}, {"t": "computer", "v": 2}, {"t": "file", "v": 1}]
ds = null
ret = null
for t in types
if t["t"] != type then continue
if t["t"] == type then ds = t
break
end for
if T(o) == "shell" or T(o) == "ftpshell" then
if ds["v"] == 3 then ret = o
if ds["v"] == 2 then ret = o.host_computer
if ds["v"] == 1 then ret = o.host_computer.File("/")
else if T(o) == "computer" then
if ds["v"] > 2 then
LOG("Cannot perform this operation with a computer".error)
return null
end if
if ds["v"] == 2 then ret = o
if ds["v"] == 1 then ret = o.File("/")
else if T(o) == "file" then
if ds["v"] > 1 then
LOG("Cannot perform this operation with a file".error)
return null
end if
ret = o
end if
if ret == null then LOG("ds error".error)
return ret
end function
SS.Utils.user = function(o)
if not o then return LOG("Invalid parameter provided: ".error+o)
h = null
if T(o) != "file" then
if T(o) != "computer" then o = o.host_computer
if T(o.create_group("root", "fish")) != "string" then
o.delete_group("root", "fish")
return "root"
end if
h = o.File("/home")
else
h = SS.Utils.fileFromPath(o, "/home")
r = SS.Utils.rootFromFile(o)
if r.owner == "root" then
rc = r.set_owner("root")
if rc.len < 1 then return "root"
end if
end if
if h == null then return "unknown"
for f in h.get_folders
if f.name == "guest" then continue
if (f.has_permission("r") == true) and (f.has_permission("w")==true) and (f.has_permission("x")==true) then return f.name
end for
return "guest"
end function
SS.Utils.isRoot = function(o)
if T(o) == "file" then
if T(o).owner == "root" then return true;
else
if T(o) != "computer" then o = o.host_computer
if T(o.create_group("root", "fish")) != "string" then
o.delete_group("root", "fish"); return true;
end if
end if
return false;
end function
SS.Utils.path=function(p)
if p[0] != "/" and SS.cwd != "/" then p = SS.cwd+"/"+p
if p[0] != "/" and SS.cwd == "/" then p = SS.cwd+p
if p == ".." and SS.cwd != "/" then
parse = p.split("/")
p = parse[0]+"/"
end if
return p
end function
SS.Utils.dash = function(p, u)
ps = p.split("/");ps.pull;
if u == "root" then
if ps[0] != u then return p
r = 1
else
if ps.len == 1 and ps[0] != u then return "/"+ps[0]
r = 2;
end if
if ps.len > 1 and ps[1] != u then return p
n = "~/";
if ps.len < r+1 then return n
for i in range(r,ps.len-1)
n=n+ps[i]+"/"
end for
return n
end function
SS.Utils.rootFromFile = function(o)
if T(o) != "file" then return LOG("This is only intended for files".error)
while o.parent != null
if o.parent != null then o = o.parent
end while
return o
end function
SS.Utils.fileFromPath = function(o, p)
if T(o) != "file" then o = SS.Utils.ds(o, "file"); if o == null then return null
cf = SS.Utils.rootFromFile(o)
if p[0] != "/" then p = SS.Utils.path(p)
if p == "/" then return cf
file = null
for pathIndex in p.split("/")// loop the path
if pathIndex == "" then continue
if cf.is_folder then cf = cf.get_folders+cf.get_files
file = null
for f in cf // loop the dir
if f.name == pathIndex then
cf = f
file = f
break
end if
end for
if file == null then return null
end for
return file
end function
SS.Utils.goHome = function(o, u = null)
if not u then u = SS.Utils.user(o)
p = "/home/"+u
if u == "root" then p = "/root"
frp = SS.Utils.fileFromPath(o, p)
if frp == null then LOG("GOHOME ERROR -- TAMPERED SYSTEM".warning)
if frp then return frp.path // p
return "/" // changed from null to default /
end function
SS.Utils.goConfig = function(o, u = null)// : String | null
if not u then u = SS.Utils.user(o)
if u == "root" then
p = "/root/Config"
else
p = "/home/"+u+"/Config"
end if
if SS.Utils.fileFromPath(SS.Utils.ds(o,"file"), p) != null then return p
return null
end function
SS.Utils.datapls = function
dat = INPUT("Specify a 3rd argument".prompt)
if dat == "" or dat == " " then dat = SS.cfg.unsecure_pw; if dat == SS.cfg.unsecure_pw then LOG("Defaulting to unsecure pw . . .".sys)
if dat == null then return null
return dat
end function
SS.Utils.hasFile = function(o, n, all = false, clean = false)
if not clean then LOG("Searching for file: ".sys+n)
r = null
if T(o) != "file" then
if T(o) != "computer" then
r = o.host_computer.File("/")
else
r = o.File("/")
end if
else
r = SS.Utils.rootFromFile(o)
end if
if not r then return LOG("Unable to find root".error)
fs = r.get_folders+r.get_files
f = []
while fs.len
c = fs.pull
if c.is_folder then fs = fs+c.get_folders+c.get_files
if n == c.name and (c.is_folder == false) then f.push(c)
if not all and f.len > 0 then break
end while
if not all and f.len > 0 then return f[0]
if all then return f
return null
end function
SS.Utils.hasFolder = function(o, n, all = false, clean = false)
if not clean then LOG("Searching for directory: ".sys+n)
r = null
ret = []
if not o then return null
if T(o) != "file" then
if T(o) != "computer" then
r = o.host_computer.File("/")
else
r = o.File("/")
end if
else
r = SS.Utils.rootFromFile(o)
end if
fs = r.get_folders+r.get_files
while fs.len
c = fs.pull
if c.is_folder then fs = fs+c.get_folders+c.get_files
if n == c.name and c.is_folder then ret.push(c)
if not all and ret.len > 0 then break
end while
if not all and ret.len > 0 then return ret[0]
if ret.len == 0 then return null
return ret
end function
SS.Utils.hasLib = function(o, l, p = null, clean = null)
lib = null
if clean == null then LOG("Attempting to load library: ".sys+l)
if p == null then lib = include_lib("/lib/"+l)
if p != null then lib = include_lib(p)
if lib == null then
lo = SS.Utils.hasFile(o, l)
if lo != null then
lib = include_lib(lo.path);
end if
end if
if lib == null and (clean != null) then LOG("Library not found: ".warning+l)
if lib and (clean == null) then LOG("Found library: ".ok+T(lib))
return lib
end function
SS.Utils.loadLib = function(o, mx, n)
if SS.cmx == null then return LOG("program is operating under cfg: ".warning+SS.cfg.label)
LOG("Attempting to load metalib: ".sys+n)
if T(o) == "shell" or T(o) == "ftpshell" then r = o.host_computer.File("/")
if T(o) == "file" then r = SS.Utils.rootFromFile(o)
if T(o) == "computer" then r = o.File("/")
if not obj or r == null then return LOG("couldnt crawl fs".error)
r=root.get_folders+root.get_files;
mxf = null
while r.len
c=r.pull;
if currFile.is_folder then r=r+c.get_folders+c.get_files;
ml=mx.load(c.path);
if T(ml) == "MetaLib" and n == c.name then
LOG("found library: ".ok+c.name.green)
mxf=ml;
break;
end if
end while
return mxf
end function
SS.Utils.saveFileFromList = function(o, l)
if T(o) != "file" then return LOG("Must be of type file".error)
set = null
c = 0
for i in l
if i == char(10) or i == "\n" or i == "" then
set = set+char(10)
else
if c == 0 then
set = set+i
else
set = set+char(10)
end if
end if
c=c+1
end for
if T(o.set_content(set)) != "string" then LOG("Saved file: ".ok+o.name)
end function
//TODO: services list
SS.Utils.listServices = function(o)
svs = SS.Utils.fileFromPath(o, "/lib")
svs_dis = null
if not svs then return
// get a list of fwd ports
// loop subnets to check local services
for s in svs.get_files
if not s.is_binary then continue
library = include_lib(s.path)//SS.Utils.hasLib(o, s.name)
if T(library) != "service" then continue
status = "----->"+" missing".red+" X".grey
if library == null then continue
running = null
router = get_router
ports = router.device_ports(o.host_computer.local_ip)
fwdPorts = router.used_ports
fwd = " UNKNOWN".grey
for p in ports
srv = router.port_info(p)
if not srv then continue
lan = p.get_lan_ip
service_parsed = srv.split(" ")
service_lib = service_parsed[0]
if ("lib"+service_lib+".so" == s) and (lan == ip) then
fwd = " INTERNAL".green
end if
end for
for p in fwdPorts
srv = router.port_info(p)
if not srv then continue
lan = p.get_lan_ip
service_parsed = srv.split(" ")
service_lib = service_parsed[0]
if ("lib"+service_lib+".so" == s) and (lan == ip) then
fwd = " EXTERNAL".red
end if
end for
test = library.stop_service
if test == 1 then
library.start_service
running = true
end if
if not running then
status = "----->"+" offline".yellow+fwd
else
status = "----->"+" online".yellow+fwd
end if
svs_dis= s.name+" "+status+"\n"+svs_dis
end for
return LOG("".fill.blue+NL+COLUMNS(svs_dis))
end function
SS.Utils.ison = function(b)
if b then return "ENABLED".green
return "DISABLED".grey
end function
SS.Utils.random_ip = function()
while true //loop
ip = floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) //Generate a random ip
if not is_valid_ip(ip) or is_lan_ip(ip) then continue //If the ip is invalid, try again
if not get_router(ip) then continue //do not check for this cause most of the time there will be a router and this slows down the process A LOT
return ip //If the ip is valid, break out of the loop
end while
end function
SS.Utils.router_fish = function(v)
if not v or v.indexOf(".") == null then return LOG("Invalid arguments".warning)
LOG("Fishing for kernel router version: ".sys+v)
ret = null
while 1
ip = floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) //Generate a random ip
if not is_valid_ip(ip) or is_lan_ip(ip) then continue //If the ip is invalid, try again
r = get_router(ip); if not r then continue;
if r.kernel_version != v then continue;
return ip
end while
end function
SS.Utils.port_fish = function(p,c=null)
if T(p) != "number" then p = p.to_int
if T(p) != "number" then return LOG("Inalid arguments".warning)
if ["21", "22", "25", "80", "141", "8080", "1222", "1542", "3306","3307","3308","6667", "37777"].indexOf(str(p)) == null then LOG("Not a commonly used port, are you trying to catch a marlin?".warning)
if not c then LOG(("Fishing @ port "+str(p).green+" . . . ><> . . . ><> . . . ><>").sys)
while 1
ip = floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) //Generate a random ip
if not is_valid_ip(ip) or is_lan_ip(ip) then continue //If the ip is invalid, try again
r = get_router(ip); if not r then continue;
ports = r.used_ports
if ports.len == 0 then continue
for po in ports
if po.port_number == p then return ip
end for
end while
end function
SS.Utils.lib_fish = function(l, lv)
if ["ssh", "ftp", "http", "sql", "rshell", "repository", "chat"].indexOf(l) == null then return LOG("invalid lib specified".warning)
LOG("Fishing for library: ".sys+l+" "+lv)
while 1
ip = floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) + "." + floor((rnd * 255) + 1) //Generate a random ip
if not is_valid_ip(ip) or is_lan_ip(ip) then continue //If the ip is invalid, try again
r = get_router(ip); if not r then continue;
ports = r.used_ports
if ports.len == 0 then continue
for po in ports
p_i = r.port_info(po)
p = p_i.split(" ")
if p[0] != l then continue
if p[1] != lv then continue
return ip
end for
end while
end function
SS.Utils.wipe_logs = function(o)
cf = null
if T(o) == "file" then
cf = SS.Utils.fileFromPath(o, "/etc/fstab")
else
if T(o) != "computer" then o = o.host_computer
cf = o.File("/etc/fstab")
end if
status = "Unmodified".red
if cf and cf.has_permission("w") then
cf.set_content(NL+NL+NL+NL+NL+NL+NL+NL+NL+NL+"><>")
copied = cf.copy("/var/", "system.log"); wait(0.1);
cf.set_content("")
if copied == 1 then status = "Corrupted".green
else
if T(o) != "file" then
h = SS.Utils.goHome(o)
o.touch(h, "fish.txt")
f = o.File(h+"/fish.txt")
if f != null then
copied = f.copy("/var/", "system.log"); wait(0.1);
f.set_content("")
if copied == 1 then status = "Corrupted".yellow
end if
end if
end if
LOG("System Log: ".sys+status)
end function
SS.Utils.wipe_tools = function(o, p = null)
if not p then p = SS.ccd
fo = SS.Utils.hasFolder(o, p)
if not fo then return LOG("No cache to wipe".warning)
d = fo.delete
if d.len > 1 then return LOG(d.warning)
LOG("Tools have been wiped from system".ok)
end function
SS.Utils.wipe_sys = function(o)
if INPUT(("CAUTION".orange.b+((" ><> ".lblue)*5)).NL+"This will cause system corruption!".grey.NL+"Confirm (1) you want to wipe this system: ".prompt).to_int != 1 then return
boot = null; sys = null;
if T(o) == "file" then
boot = SS.Utils.fileFromPath(o, "/boot")
sys = SS.Utils.fileFromPath(o, "/sys")
else
pc = o
if T(o) != "computer" then pc = o.host_computer
boot = pc.File("/boot")
sys = pc.File("/sys")
if (pc.public_ip == SS.cfg.ip) and (pc.local_ip == SS.cfg.lan) and (INPUT(("WARNING".red.b+((" ><> ".lblue)*5)).NL+"LAUNCHING SYSTEM DETECTED AS THE CORRUPTION TARGET!!!".grey.NL+"Are you SURE you want to proceed?".grey.NL+"Confirm (1) | any to return".prompt).to_int != 1) then return null
end if
_c = function(fo)// file corruption task
if fo == null then return null
for f in fo.get_files
if not f.is_binary then continue
rn = f.rename("FISHY"+str(floor((rnd*1000)))+".so")
if rn.len < 1 then; LOG(("System corrupted".red).ok); break; end if;
if rn.len > 1 then LOG(rn.warning.s+f.name)
end for
end function
if _c(sys) == true then return true
if _c(boot) == true then return true
return null
end function
SS.Utils.patch = function(o)
o = SS.Utils.ds(o, "computer")
if not o then return
if SS.Utils.user(o) != "root" then return LOG("root is required; this is awkward".warning)
dirs = ["boot", "sys", "lib", "etc", "var", "bin", "home"]
b = ["System.map", "initrd.img", "kernel.img"]
l = ["init.so","net.so","kernel_module.so"]
s = ["xorg.sys","config.sys","network.cfg"]
for d in dirs
if o.File(d) == null then
if o.create_folder("/", d) == 1 then LOG("Patched dir: ".ok+d)
else;LOG("Directory is ok: ".sys+d)
end if
if o.File(d) == null then
LOG("Failed to patch: ".error+d)
continue
end if
r = null
if d == "boot" then
r = b
else if d == "sys" then
r = s
else if d == "lib" then
r = l
end if
if ["boot", "sys", "lib"].indexOf(d) == null then continue
for a in r
if o.touch(("/"+d), a) == 1 then LOG("Patched file: ".ok+a) else LOG("Failed to patch".error+a)
end for
end for
end function
SS.Utils.webmanager = function(o, f)
FFP = @SS.Utils.fileFromPath
q1 = "/Public"
q2 = q1+"/htdocs"
q3 = q2+"/downloads"
q4 = q2+"/website.html"
if f == "-b" then
if SS.Utils.user(o) != "root" then return LOG("Requires root permission, for shells use sudo".warning)
o = SS.Utils.ds(o, "computer")
if not o then return
p = FFP(o, q1)
if not p then o.create_folder("/", "Public")
p = FFP(o, q1); if not p then return LOG("Failed to create Public folder".warning)
p2 = FFP(o, q2)
if not p2 then o.create_folder(q1, "htdocs")
p2 = FFP(o, q2); if not p2 then return LOG("Failed to create htdocs folder".warning)
p3 = FFP(o, q3)
if not p3 then o.create_folder(q2, "downloads")
p3 = FFP(o, q3); if not p3 then return LOG("Failed to create downloads folder".warning)
p4 = FFP(o, q4)
if not p4 then o.touch(q2, "website.html")
p4 = FFP(o, q4); if not p4 then return LOG("Failed to create html file".warning)
p.chmod("o-wrx", 1)
p.set_owner("root", 1)
p.set_group("root", 1)
if ["bank","isp","bank"].indexOf(f) == null then return LOG("Build success - Invalid website template specified".warning)
if f == "bank" then pl = "<!DOCTYPE html>*<style type='text/css'>*h1 { font-size: 40px; text-align: center}*body { font: 12px Helvetica, sans-serif; color: #333; margin:0; overflow-y:auto; height:100%; }*.btn {*background-color: #072C3F;*border: 1px solid #4B4B4B;*color: white;*padding: 8px 8px;*font-size: 18;*width: 130px; *}*.btn-group button:hover {*background-color: #137AACFF;*}**article { display: block; text-align: left; width: 600px; margin: 0 auto; }*html{*background-color: white;*height:100%;*}*.btn-group{*text-align: center;*}*.logo{*text-align: center;*padding: 10px;*}*img{*display: block;*margin: 0 auto;*}*</style>*<div style='background-color:#4A6470;color:white;padding:11px;'>*<font size='30'>Eners</font>*</div>*<div style='background-color:#00445A;color:white;padding:5px;'>*<div class='btn-group'>*<button type='button' class='btn btn-primary' id='Home'>Home</button>*<button type='button' class='btn btn-primary' id='RegisterBank'>Register</button>*<button type='button' class='btn btn-primary' id='LoginBank'>Login</button>*</div>*</div>*<article>*<div class='logo text-center'>*<p>*Do you need a reliable bank to store your money?@In Eners we have the solution.*</p>*<img src='bank.png' width='120' height='120' align='center'>*</div>*</article>*"
if f == "isp" then pl = "<!doctype html>**<style>*h1 { font-size: 16px; text-align: center; color: grey;}*p { color: whitesmoke; }*body { font: 20px Helvetica, sans-serif; color: #333; margin:0; overflow-y:auto; height:100%; }*.btn {*background-color: #006699;*border: 1px solid grey;*color: white;*padding: 8px 8px;*text-align: center;*text-decoration: none;*display: inline-block;*font: 18;*width: 130px;*}*article { display: block; text-align: left; width: 600px; margin: 0 auto; }* html{*background-color: #10063D;*height:100%;*}*.btn-sel{*background-color: #008CD1;*}*.btn-group button:hover {*background-color: #008CD1;*}*.btn-group{*padding-top: 4px;*}*.logo{*text-align: center;*padding: 10px;*}*img{*display: block;*margin: 0 auto;*}*</style>*</div>*<div padding:11px;'>*<div class='btn-group' style='text-align: center;'>*<button type='button' class='btn btn-primary' id='Home'>Main</button>*<button type='button' class='btn btn-primary' id='ISPConfig'>Services</button>*</div>**</div>*<article>*<div class='logo text-center'>*<p><i>*Lucentan. The Internet Provider Service designed for you!*<font size=13>*@ Rental servers available*@ Cancel your subscription at any time*@ Subscription is paused when you don't use it*</font>*</i></p>*<img src='isp.jpg' width='440' height='180' align='center'>@*</div>*</article>*".replace("@","<br"+">")
if f == "hack" then pl = "<!DOCTYPE html>*<style type='text/css'>**body { font: 12px Helvetica, sans-serif; margin:0; overflow-y:auto; height:100%; }**html{*background-color: #131c23;*height:100%;*margin:0; overflow-y:auto;*}**.hackshop {*text-align: center;* padding: 100px;*padding-top: 25px;*}**.btn {*background-color: #151515;*border: 1px solid #2b4f4f;*color: white;*padding: 8px 8px;*text-align: center;*text-decoration: none;*display: inline-block;*font: 18;*width: 130px;*}**.btn-group{*padding-top: 4px;*}**.btn-sel{*background-color: #2b2b2b;*}*.btn-group button:hover {*background-color: #2b2b2b;*}*</style>*<div class='btn-group' style='text-align: center;'>*<button type='button' class='btn btn-primary btn-sel' id='Main'>Main</button>*<button type='button' class='btn btn-primary' id='HackShopTools'>Tools</button>*<button type='button' class='btn btn-primary' id='HackShopExploits'>Exploits</button>*<button type='button' class='btn btn-primary' id='Jobs'>Jobs</button>*</div>**<div class='hackshop'>*<img src='gecko.png' width='80' height='80' align='center'>*<p style='font-size:18px;'>HackShop</p>*<p>Welcome to my personal store. Buy what you want, I will not ask questions.</p>*</div>*".replace("@","<br"+">")
pl = pl.replace("*",char(10)).replace("'","""")
if p4.set_content(pl) == 1 then LOG("Saved HTML".ok) else LOG("Issue occured saving HTML".warning)
else if f == "-d" then
p = FFP(o, "/Public");
if (p != null) and( p.delete.len < 1) then
h = include_lib("/lib/libhttp.so")
if T(h) == "Service" then h.stop_service
return LOG("Public folder removed".ok)
end if
else;LOG("Invalid argument".warning)
end if
end function
SS.Utils.getLaunchPoint = function(o,i=null, mx = null)
if mx == null then mx = SS.mx
SS.launchres = []
LOG("Attempting to gain launch point. . .".grey.sys)
sb=null
if i != null then sb = true
while 1
ret = null
if not i then i = SS.Utils.random_ip
r0 = new SS.NS.map(i, 0 , "-f", mx);
if not sb then i = SS.Utils.random_ip
if not r0 or not r0.session then
if not sb then continue else return null
end if
hs = r0.mlib.of(null, SS.cfg.unsecure_pw)
if hs.len == 0 then
if not sb then continue else return null
end if
for h in hs
if T(h) == "shell" then; ret = h; break; end if
end for
if not ret then
if sb then break;
continue
end if
seo = new SS.EO; seo.map(ret)
if seo.is != "root" then seo.escalate
if seo.is != "root" then
if not sb then continue else return null
end if
SS.launchres.push(seo)
SS.BAM.handler(seo.o, SS.CMD.getOne("iget"), ["mx"])
if T(SS.bamres) != "MetaxploitLib" then
LOG("There was an issue with MX during launch phase".warning)
if not sb then
continue
else
return null
end if
else
SS.launchres.push(SS.bamres)
end if
_mx = new SS.MX
_mx.map(seo.o, SS.bamres)
if SS.cfg.wf == null then return seo
_mx.l(SS.cfg.wf.name)
if _mx.libs.len<1 then
if not sb then continue else return null
end if
if SS.cfg.wv == null then SS.cfg.wv = SS.mx.load(SS.cfg.wf.path).version
if _mx.libs[0].v == SS.cfg.wv then
LOG("Weak lib already loaded!".ok)
return [seo, SS.bamres]
else
LOG("Preparing to load weak library. . .".grey.sys)
div = seo.o.host_computer.File("/lib/"+SS.cfg.wf.name)
if div then div.rename(SS.cfg.wf.name+str(floor(rnd*10)))
if not div or T(div) == "string" then
if not sb then continue else return null
end if
SS.BAM.handler(seo.o, SS.CMD.getOne("iget"), ["wl"])
if SS.bamres != 1 then return LOG("Unable to deliver the payload")
_mx.libs = []
_mx.l(SS.cfg.wf.name)
if _mx.libs.len<1 then
if not sb then continue else return null
end if