-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy path5hell.5pk.src
More file actions
2870 lines (2840 loc) · 141 KB
/
5hell.5pk.src
File metadata and controls
2870 lines (2840 loc) · 141 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
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
// 5hell v 4.3.0 by Plu70
// released v 4.3.1
// imports .5pk files from /root/src
// globals
ver = "4.3.6_falling_skies"
//print ver
if not globals.hasIndex("DEBUG") then globals.DEBUG = false // set to true by launching 5hell with --debug as any parameter
if globals.hasIndex("params") and globals.params.indexOf("--debug") >= 0 then
globals.DEBUG = true
globals.params.remove(globals.params.indexOf("--debug"))
end if
size_of_5hell = "144.577"
globals.SILENT = 0 // 0 == normal, 2 == silent, 1 == clear_screen
if DEBUG then print("<size=75%>loading globals...</size>") else print("<align=center><mark=red><color=black>#</color></mark></align>")
//
EXPERIMENTAL = true // superfluous
NOBUFF = false // if true: prompt does not push input to Terminal buffer
//
// INITIALIZE GLOBALS SOON(tm)
//if not get_custom_object.hasIndex("glob") then get_custom_object.glob = {}
//
// these three stubs are set below by super_import
globals.metaxploit = null
globals.crypto = null
globals.apt_get = null
//
//
// register macros
if DEBUG then print("<size=75%>confirming macros...")
if not get_custom_object.hasIndex("macros") then get_custom_object.macros = {}
//
//
globals.localip = function()
return localmachine.local_ip
end function
globals.pubip = function()
return localmachine.public_ip
end function
//
globals.BIGBRAIN = false
//globals.HASH_TABLE = {} // we'll revisit this idea later
globals.GLASSPOOL = 0
globals.metaLib = null
globals.debugLib = null
globals.net_session = null
globals.backup_meta = null
globals.tagged_for_scp = ""
globals.neurobox_user = ""
globals.neurobox_pass = ""
globals.clip_board_delta = "" // for do
globals.debug_username = ""
globals.debug_password = "" // neurobox debug credentials
//
globals.command_buffer = []
globals.enumerated = []
globals.shell = get_shell
globals.localmachine = shell.host_computer
globals.currentPath = current_path
globals.homePath = home_dir
globals.instance = globals.localmachine.File(program_path)
globals.T_BUF = [(localip+"@"+pubip)] // transmission buffer
globals.BUFFER = [get_shell]
//
globals.spoolpath = 0 // 0 false, string true
globals.SAFEWORD = "@STOP" // use @STOP (or this value) in a do script and/or in an if statement within a do script to 'break' the do loop
globals.HERMES = false
globals.inbox = null
//
globals.grepped_file = null
globals.airing = false
globals.mail_user = null
globals.last_mail = null
globals.this_mail = 0
//
globals.XPLOITS = []
globals.MEMORY = null
globals.meta_scan = []
//
globals.routerLib = null
globals.portInfo = null
globals.tarLan = null
globals.last_whois = ""
globals.brdc = ""
globals.PORT_MAP = {}
globals.targetIP = null
globals.targetPort = "router"
//
//
if DEBUG then print("<size=75%>loading dictionary...</size>")
// this function puts the dictionary in the custom object for use between nested launches without breaking legacy dictionary calls
globals.dict_a = function(import=0)
cobble = get_custom_object
if typeof(import) == "list" then cobble.dictionary = import // set a new dicitonary from input: list
if not cobble.hasIndex("dictionary") then cobble.dictionary = ["a"] else globals.BIGBRAIN = true // set default dictionary if it doesn't exist
return cobble.dictionary // return the dictionary in all cases as a list
end function
//// UPDATING THE DICTIONARY IS HANDLED BY COMMAND.CEREBRUM //////
if DEBUG then ds = dict_a.len
if DEBUG then print("<size=75%>dictionary loaded...("+(ds/1000)+"kb)</size>")
//
// import 5phinx -- this contains critical shared functions and the backbone of the hacking suite
// Do not remove the comment in the next line, it is necessary for Greybel support
import_code("/root/src/5phinx.5pk") // override=5phinx.5pk
//
// set globals.metaxploit, globals.crypto, globals.apt_get
globals.super_import // located in 5phinx.5pk; include_lib latest of: metaxloit, crypto, aptclient
//
// import kore.5pk -- kore's domain
// Do not remove the comment in the next line, it is necessary for Greybel support
import_code("/root/src/kore.5pk") // override=kore.5pk
//
// import dtools.5pk -- dev/dictionary tools
// Do not remove the comment in the next line, it is necessary for Greybel support
import_code("/root/src/dtools.5pk") // override=dtools.5pk
//
// import contrib.5pk -- this contains shared functions and commands contributed by the community
// Do not remove the comment in the next line, it is necessary for Greybel support
import_code("/root/src/contrib.5pk") // override=contrib.5pk
//
// import net.5pk -- networks tools
// Do not remove the comment in the next line, it is necessary for Greybel support
import_code("/root/src/net.5pk") // override=net.5pk
//
// import help.5pk -- the help command and associated extra documentation
// Do not remove the comment in the next line, it is necessary for Greybel support
import_code("/root/src/help.5pk") // override=help.5pk
//
// globals.dmanager = new DaemonManager // now handled by command.dm
// dmanager.Init
//
// end globals
if DEBUG then print("<size=75%>loaded get_file...")
if DEBUG then print("<size=75%>loading 5hell.5pk...("+size_of_5hell+"kb)") /////LOADING 5HELL////////////
if DEBUG then print("<size=75%>loading clip commander...(666 licks to the center)")
// consolidate all clipX's into one clipboard command
// newclip, to combine all clips
// begin clip commander
// expand by adding a CLIP map index and creating a corresponding command.[yourclip] = function(...) call below _clipboard (use existing ones as templates)
CLIP = {"a":"","b":"","c":""}
_clipboard = function( index, arg1, arg2 )
// index checking is done at command.clip[x] calls
cw = colorWhite
clip = {}
clip.msg = colorCyan+"</b>clip"+colorWhite+index+CT+"</color>"
clip.hlp = "clipboard || clipa || clipb || clipc || clippy dippy"+char(10)+
"There are, by default, three clipboard spaces: clipa, clipb, clipc. It is"+char(10)+
"possible to expand beyond this limit by adding entries to the CLIP map in 5hell.5pk."+char(10)+
"The clipboards may store any data type or game object. "+char(10)+
char(10)+
"EZ_CLIP allows use of aliases:"+char(10)+
"--: "+cw+"@a"+CT+" for clip"+cw+"a"+CT+", "+cw+"@b"+CT+" for clip"+cw+"b"+CT+", and "+cw+"@c"+CT+" for clip"+cw+"c"+char(10)+
"---- when you want to reference the clipboard in an argument."+char(10)+
"For example: "+char(10)+
colorGrey+"|> "+cw+"clipa foobar"+char(10)+
colorGrey+"|> "+cw+"echo @a"+char(10)+
colorGrey+"<b>foobar"+char(10)+
char(10)+
"The clipboard spaces start out as an empty string, by default. "+char(10)+
"You may edit text in the clipoard directly with:"+char(10)+
colorGrey+"|> "+colorWhite+"scribus "+colorMagenta+"@"+colorLightBlue+"clip"+colorWhite+"[a|b|c]"+char(10)+
"--eg: scribus "+colorWhite+"@clipa"+CT+" | poke magnum.opus | lock"+char(10)+
"--<b>note</b>: scribus @clipa edits the clipboard's text"+char(10)+
"--<b>note</b>: scribus @a will not edit clipa but rather:"+char(10)+
"---- if clipa is a list of strings: will open the editor on the array and return an array"+char(10)+
"---- if clipa is a string: will attempt to edit a file whose name matches the first word in the string "+char(10)+
"---- if clipa is a text file: will edit the file"+char(10)+
char(10)+
colorGreen+ "Viewing help for "+clip.msg+char(10)+
colorCyan+"</b>Usage: "+clip.msg+" -- returns the contents of "+clip.msg+char(10)+
"-- stored functions are returned as a reference"+char(10)+
colorGold+"</b>Usage: "+clip.msg+" [<b>any_value</b>] -- set "+clip.msg+" to any value"+char(10)+
"-- piped objects are stored and returned as objects"+char(10)+
"-- piped functions are stored and returned as function references"+char(10)+
"-- piped strings, including piped (string: integers), are stored and returned as strings"+char(10)+
"-- piped integers are stored and returned as integers"+char(10)+
"--nb: you may cast a string to an int with:"+char(10)+
"----:<b> clipa [+=|-=] 0"+char(10)+
"---eg: <b>clipa 12 || clipa += 0"+char(10)+
colorCyan+"</b>Usage: "+clip.msg+" [<b>-z</b>] -- set "+clip.msg+" to "+cw+"int: zero"+char(10)+
"-- passing <b>0</b> as an argument sets "+clip.msg+" to <b>string: 0"+char(10)+
"-- piping in an <b>int: 0</b> results in no_argument behavior: it returns "+clip.msg+char(10)+
colorCyan+"</b>Usage: "+clip.msg+" [<b>-n</b>] -- set "+clip.msg+" to "+colorMagenta+"</b>null"+char(10)+
"-- this is useful in sme cases"+char(10)+
"-- note: the default starting state is an empty string"+char(10)+
"---- it no longer defaults to null"+char(10)+
colorCyan+"</b>Usage: "+clip.msg+" [<b>++|--</b>] -- increment | decrement "+clip.msg+" by 1"+char(10)+
"-- old way:<b> clipa 0 || calc @a [+|-] 1 | clipa"+char(10)+
"-- new way:<b> clipa 0 || clipa [++|--]"+char(10)+
colorCyan+"</b>Usage: "+clip.msg+" [<b>+=|-=</b>] [int] -- increment | decrement "+clip.msg+" by int"+char(10)+
"-- only ints or (string: ints) may by [inc|dec]remented"+char(10)+
"Advanced options:"+char(10)+
colorCyan+"</b>Usage: "+clip.msg+" [<b>@cc</b>] -- set "+clip.msg+" to the command buffer"+char(10)+
colorCyan+"</b>Usage: "+clip.msg+" [<b>@tbuf</b>] -- set "+clip.msg+" to the transmission buffer"+char(10)+
"--eg:<b> tree || gopher @tbuf"+char(10)+
colorCyan+"</b>Usage: "+clip.msg+" [<b>@B</b>] [<b>-m|#</b>] -- set "+clip.msg+" to "+colorOrange+"BUFFER[#]"+char(10)+
"-- passing <b>-m</b> instead of an index will prompt for selection with the BUFFER menu"+char(10)+
"NOTE: @tbuf, and @B are now available to <b>all</b> commands via ez_clip"+char(10)+
"--eg:<b> clipa @B 1 || clipb "" /home/guest/rkit/5hell "" || run @b @a"+char(10)+
"--eg:<b> run /home/guest/rkit/5hell @B -m"+char(10)+
"NOTE: it is important to distinguish between "+char(10)+
"-- "+cw+"@b"+CT+" -- clipb reference, and"+char(10)+
"-- "+colorOrange+"@B"+CT+" -- BUFFER reference"+char(10)+
"eg: <b>clipb foobar || echo @b </b>vs<b> zap || gp @B 1"+char(10)+
"-- see help alias for a full list of ez_clip aliases"+char(10)+
"Note: all (successful) uses of "+clip.msg+" will return the value of "+clip.msg+char(10)+char(10)+
"See Also: cob -h, help alias, help buffer"
if @arg1 == "help" or @arg1 == "-h" then return clip.hlp
clip.clp = @arg1
if DEBUG then print "debug: clipboard: "+char(10)+"--<b> arg1: "+@arg1+", arg2: "+@arg2
if typeof(@arg2) == "string" then arg2 = arg2.to_int
if @arg1 == "++" or @arg1 == "--" then arg2 = 1
clip.add = function()
if DEBUG then print "--- clipping: "+@clip.clp
if @arg1 then
globals.CLIP[outer.index] = @clip.clp
print clip.msg+": clipped: "+typeof(@CLIP[outer.index])
end if
return @CLIP[outer.index]
end function
clip.n = function()
clip.clp = null
end function
clip.z = function()
clip.clp = 0
end function
clip.up = function()
if typeof(@outer.arg2) != "number" then; print clip.msg+": += expects integer";return;end if
add = @CLIP[outer.index]
if typeof(@add) == "string" then add = add.to_int
if typeof(@add) != "number" then; print clip.msg+": cannot increment "+typeof(@add);outer.arg1 = 0;return;end if
clip.clp = add + outer.arg2
clip.clp = str(clip.clp)
end function
clip.dn = function()
if typeof(@outer.arg2) != "number" then; print clip.msg+": += expects integer";return;end if
sub = @CLIP[outer.index]
if typeof(@sub) == "string" then sub = sub.to_int
if typeof(@sub) != "number" then; print clip.msg+": cannot decrement "+typeof(@sub);outer.arg1 = 0;return;end if
clip.clp = sub - outer.arg2
clip.clp = str(clip.clp)
end function
// legacy compat:
clip.tbf = function()
globals.T_BUF.pull
clip.clp = globals.T_BUF
globals.T_BUF = [(localip+"@"+pubip)]
end function
clip.cc = function()
clip.clp = globals.command_buffer.join(char(10))
end function
clip.bf = function()
if globals.BUFFER.len < 1 then print clip.msg+"malp: BUFFER is empty."
i = 0
for b in globals.BUFFER
print("["+colorWhite+i+CT+"] - <b>"+checkUser(@b)+":"+typeof(@b)+"</b>")
i = i + 1
end for
indx = @outer.arg2
if typeof(@indx) == "string" then
if indx == "-m" then indx = user_input("clip:> ").to_int else indx = indx.to_int
end if
if typeof(@indx) == "number" and indx >= 0 and indx < BUFFER.len then clip.clp = @globals.BUFFER[indx] else clip.clp = clip.msg+": @B: invalid buffer selection."
end function
// end_legacy_compat
clip.rtrn = function()
clip.clp = 0
end function
_=function();end function
// start switch
if typeof(@arg1) == "function" then return clip.add
switch(@arg1)
case("-n", @clip.n)
case("-z", @clip.z)
case("++", @clip.up)
case("--", @clip.dn)
case("+=", @clip.up)
case("-=", @clip.dn)
case("@tbuf", @clip.tbf)
case("@cc", @clip.cc)
case("@B", @clip.bf)
case(0, @clip.rtrn)
if DEBUG then print "clip: switch: firing"
default(@_)
return clip.add
end function
// expand the clipboard by adding a function associated with an entry to the CLIP map above the _clipboard() function
command.clipa = function(arg1,arg2,arg3,arg4)
return @_clipboard("a",@arg1,@arg2)
end function
command.clipb = function(arg1,arg2,arg3,arg4)
return @_clipboard("b",@arg1,@arg2)
end function
command.clipc = function(arg1,arg2,arg3,arg4)
return @_clipboard("c",@arg1,@arg2)
end function
// end clip commander
if DEBUG then print("<size=75%>loaded clip commander...")
command.passwd = function(arg1, arg2, arg3=0, arg4=0)
if arg1 == "help" or arg1 == "-h" then return "<u>Password || Change Password || passwd"+char(10)+"Usage: passwd [opt: user] [opt: password] -- change password for user"+char(10)+"- will prompt for missing options"
user = null
pass = null
if arg1 then user = arg1
if arg2 then pass = arg2
if not user then user = user_input("passwd: change password for which user? :> ")
if not pass then pass = user_input("passwd: select a new password for: "+user+":> ",1,0)
if pass == "" or pass == " " then return "aborting..."
try = localmachine.change_password( user, pass)
if try == 1 then return "passwd: "+colorWhite+"password for "+user+" updated to: "+char(10)+pass
return try
end function
command.echo = function(arg1, arg2=0, arg3=0, arg4=0)
if @arg1 == "help" or @arg1 == "-h" then return "ECHO || echo || Echo || echO"+char(10)+
"Usage: echo [up] [to] [four] [params] -- returns concatonated params to the terminal"+char(10)+char(10)+
"General usage is to echo text back to the terminal during batch script/macro execution."+char(10)+
"However, it may also be used to feed input to another command or concatonate outputs"+char(10)+
"of multiple commands. You may use floating quotes (single quotes not touching another"+char(10)+
"character) to wrap complex input parameters. Examples:"+char(10)+
"|> echo bob burger -- output: bob burger"+char(10)+
"|> echo "" Eat at Joe's Diner. "" <color=red>Because</color> "" it's the best. "" "+char(10)+
"-- output: Eat at Joe's diner. <color=red>Because</color> it's the best."+char(10)+
"|> echo three four | echo one two -- output: one two three four"+char(10)+
"Here's a fairly useless example, lol:"+char(10)+
"|> cat file.txt | echo | poke file2.txt | cat | echo | poke file3.txt"+char(10)+char(10)+
"Simple enough. You may use richtext in the echo to spruce it up."+char(10)+
"Resizing text and adding color allows the echo to stand out when text"+char(10)+
"is flying by during a complex <b>dig</b>, for example."
ec = @arg1+" "
if @arg2 then @ec = @ec + @arg2+" "
if @arg3 then @ec = @ec + @arg3+" "
if @arg4 then @ec = @ec + @arg4
return ec.trim
end function
command.clear = function(arg1, arg2, arg3=0, arg4=0)
if @arg1 == "help" or @arg1 == "-h" then return "Clear Screen || Terminal Wipe || clearscreen"+char(10)+"Usage: clear -- clears the terminal of all text"
if DEBUG then
print "debug: skipping clear_screen"
return null
end if
print("",1)
return null
end function
command.ps = function(arg1, arg2, arg3=0, arg4=0)
ps_usage = "Show Processes || PS || show procs || not actually top or htop"+char(10)+
"<b>Usage: ps [opt:-r] [opt:shell|computer] -- show processess running on the active host_computer"+char(10)+
"-- when glasspool is active:"+char(10)+
"-- the active shell/computer is the active host_computer"+char(10)+
"-- optional [-r] parameter returns raw, uncolorized output"+char(10)+
"--eg: ps -r"+char(10)+
"<b>Usage: ps [opt:-r] [shell|computer] -- show processes running on the piped object"+char(10)+
"-- optional [-r] parameter returns raw, uncolorized output"+char(10)+
"--eg: rsi 1 7 | ps"
if @arg1 == "-h" or @arg1 == "help" then return ps_usage
output = null
raw = false
verbose = false
if arg3 == "--verbose" then verbose = true
locals.hold_comp = globals.localmachine
if arg1 == "-r" then
raw = true
arg1 = arg2
arg2 = arg3
arg3 = arg4
end if
if arg1 and (typeof(arg1) == "shell" or typeof(arg1) == "computer") then
if typeof(arg1) == "shell" then locals.hold_comp = arg1.host_computer
if typeof(arg1) == "computer" then locals.hold_comp = arg1
end if
if verbose then print("<size=75%>Showing processes...")
if raw == true then return format_columns(locals.hold_comp.show_procs)
p_buf = hold_comp.show_procs.split(char(10))
i = 0
if DEBUG then print "debug: "+p_buf
for line in p_buf
if i == 0 then
line = colorWhite+"</b>"+line+"</color>".replace("USER","<color=#F5F5F5></b>USER</color>")
p_buf[i] = line
i = i + 1
continue
end if
line = colorCyan+"</b>"+line
line = line.replace("dsession",colorRed+"</b>dsession").replace("Xorg",colorLightBlue+"</b>Xorg").replace("kernel_task",colorLightBlue+"</b>kernel_task").replace("ps",colorRed+"</b>ps").replace("5hell",colorRed+"5"+colorWhite+"hell")//.replace("root",colorOrange+"<b>root</color>").replace("guest",colorWhite+"<b>guest</color>")
p_buf[i] = line
i = i + 1
end for
output = format_columns(p_buf.join(char(10)))
return output
end function
command.kill = function(arg1, arg2, arg3=0, arg4=0)
if @arg1 == 0 or @arg1 == "-h" or arg1 == "help" then return "kill || end process || terminate script"+char(10)+char(10)+
colorWhite+"Usage: kill [ALL|PID] [opt: shell|computer] -- terminate PID"+char(10)+
"-- PID should be process number or ALL"+char(10)+
"-- see the <b>ps</b> command for process ID's"+char(10)+
"--<b> kill ALL </b>will attempt to close all programs."+char(10)+
"n.b. if<b> kill ALL </b>kills the terminal that launched the program,"+char(10)+
"---- it might not complete its task."+char(10)+char(10)+
colorWhite+"Usage: kill [process_name] [opt: shell|computer] --"+char(10)+
"-- kill processes by process name instead of PID"+char(10)+
"-- NOTE: kills ALL processes of that name"+char(10)+char(10)+
colorWhite+"Advanced: kill [ALL|process_name:exclude1:exclude2:...] [opt:computer|shell]"+char(10)+char(10)+
"-- seperate process names or ID's to exclude from the kill process with the '<b>:</b>' character"+char(10)+
"-- the first process name (or the ALL keyword) will be the kill target"+char(10)+
"-- all process names or ID's following the first <b>:</b> will be excluded"+char(10)+
"-- UNLESS the kill target is a process ID"+char(10)+
"--eg: <b>kill ALL:1023:5hell [shell_obj]</b> -- kill everything on the [shell] except 5hell and 1023"+char(10)+
"--eg: <b>kill 1023:5hell [computer_obj</b> -- kill 1023 on the [computer]; no exceptions"+char(10)+
"---- ie: passing a PID ignores exceptions"+char(10)+
"--rg: <b>kill 5hell:1023</b> -- kill all instances of 5hell on the active computer except 1023"+char(10)+char(10)+
"Note: piping a shell or computer object runs kill on the object instead of locally"+char(10)+
"Note: running kill while glasspool is active runs kill on the active object"+char(10)+
"-- unless a shell or computer is piped"
target_machine = globals.localmachine
if typeof(arg2) == "shell" then target_machine = arg2.host_computer
if typeof(arg2) == "computer" then target_machine = arg2
//
PID = ""
exclude = []
if typeof(arg1) == "string" then
if typeof(arg1.to_int) == "number" then
PID = arg1.to_int
else
exclude = arg1.split(":")
PID = exclude.pull
//if typeof(PID.to_int) == "number" then PID = PID.to_int
end if
end if
if exclude.len < 1 then exclude = [""]
if typeof(PID) != "number" and typeof(PID) != "string" or PID == "" or PID == 0 then return "kill: invalid input"+char(10)+"Usage: kill [pid|process_name] [opt:shell|computer]"
//
if typeof(PID) == "string" then
processes = target_machine.show_procs.split(char(10))
killed = false
for p in processes
if p == "USER PID CPU MEM COMMAND" then continue
process = p.split(" ")
process_ID = process[1]
process_CMD = process[4]
stor = globals.localmachine
globals.localmachine = target_machine
if PID == "ALL" or PID == process_CMD or PID == process_ID then
if exclude.indexOf(process_CMD) == null and exclude.indexOf(process_ID) == null then print command.kill(process_ID)
killed = true
end if
globals.localmachine = stor
end for
if killed == false and PID != "ALL" then return "kill: process <u>" + PID + "</u> not found" else return null
end if
//
if DEBUG then print "debug: kill: PID: "+typeof(PID)+":"+PID
output = target_machine.close_program(PID)
if output == true then return("kill: terminating process: " + PID + "...");
if output then return(output)
return "kill: process <u>" + PID + "</u> not found"
end function
command.pwd = function(arg1, arg2, arg3=0, arg4=0)
if arg1 == "help" or arg1 == "-h" then return "Usage: pwd -- print working directory"+char(10)+"-- returns the current path as a string"
return currentPath
end function
command.sudo = function(user,pass,par="",arg4)
if (user == "help" and not pass) or user == "-h" then return "Usage: info"
if not user then user = "Please enter a username (-s=root, <<b>enter</b>>=abort):> "+colorWhite
if user == "-s" then user = "root"
if typeof(user) != "string" or user == "" then return "sudo: aborting..."
if not pass then pass = user_input("Please enter a password for<b> "+user+" (<<b>enter</b>>=abort)"+char(10)+":> "+colorWhite,1)
if typeof(pass) != "string" or pass == "" then return "sudo: aborting..."
odus = get_shell(user,pass)
term = null
if typeof(odus) == "shell" then
term = odus.host_computer.File("/usr/bin/Terminal.exe")
if typeof(term) != "file" then term = odus.host_computer.File("/bin/Terminal.exe")
if typeof(term) != "file" then return "sudo: unable to locate /bin/usr/Terminal.exe or /bin/Terminal.exe"+char(10)+"-- please use <b>psudo -l</b> to use <b>start_terminal</b> instead"+char(10)+"-- aborting..."
else
return "sudo: incorrect user or password"
end if
if DEBUG then print "sudo: debug: term.path: "+term.path+" : params: "+par
if typeof(par) == "string" then return odus.launch(term.path,par) else return odus.launch(term.path)
end function
command.psudo = function(operation, arg2, arg3, arg4)
if operation == "help" or operation == "-h" then return "PSUDO || sudo || get shell || get_shell || start terminal"+char(10)+
colorCyan+"<u>Start_terminal options:"+char(10)+"--"+char(10)+
"Usage: "+colorGold+"</b>psudo"+CT+" -- display the psudo menu"+char(10)+"--"+char(10)+
"Usage: "+colorGold+"</b>psudo"+CT+" ["+colorWhite+"shell_object"+CT+"] -- execute <b>start_terminal</b> on the shell_object"+char(10)+
"-- piping an object skips the confirmation prompt"+char(10)+
"-- unlike <b>run</b>, this command will <b>end</b> the script"+char(10)+"--"+char(10)+
"Usage: "+colorGold+"</b>psudo"+CT+" ["+colorWhite+"-l"+CT+"] -- execute start_terminal on the currently active shell object"+char(10)+
"-- unlike <b>run</b>, this command will <b>end</b> the script"+char(10)+"--"+char(10)+
"--nb: start_terminal results in an active trace if an administrator (root dsession) is active"+char(10)+
"---- scrub logs and disconnect as soon as your work is done to avoid a strike"+char(10)+char(10)+
colorCyan+"<u>Get_shell options:"+char(10)+"--"+char(10)+
"Usage: "+colorGold+"</b>psudo"+CT+" ["+colorWhite+"-u"+CT+"] [opt:"+colorWhite+"user"+CT+"] [opt:"+colorWhite+"password"+CT+"] -- "+colorOrange+"BUFFER"+CT+" a shell object using credentials"+char(10)+
"Usage: "+colorGold+"</b>psudo"+CT+" ["+colorWhite+"-s"+CT+"] [opt:"+colorWhite+"password"+CT+"] -- "+colorOrange+"BUFFER"+CT+" a <b>root</b> shell object using credentials"+char(10)+
"-- passing -s will prompt to open the object's menu in malp"+char(10)+
"Usage: "+colorGold+"</b>psudo"+CT+" ["+colorWhite+"-f"+CT+"] [opt:"+colorWhite+"password"+CT+"] -- as above but skips prompt and goes straight to malp"+char(10)+
"Usage: "+colorGold+"</b>psudo"+CT+" ["+colorWhite+"-n"+CT+"] [opt:"+colorWhite+"password"+CT+"] -- "+colorOrange+"BUFFER"+CT+" a shell object without prompts or malp"+char(10)+
char(10)+
"NOTE: -u, -s, -f, and -n will <b>all</b> return the shell object on success, a string on failure"
//
_psudo_menu = function()
print colorGold+"</b>psudo: "+CT+"["+colorWhite+"y</b>|<b>l"+CT+"] execute "+colorCyan+"</b>start_terminal"+CT+" on the currently active shell object"
print colorGold+"</b>psudo: "+CT+"["+colorWhite+"u"+CT+"] BUFFER a <b>local</b> user shell using credentials"
print colorGold+"</b>psudo: "+CT+"["+colorWhite+"s"+CT+"] BUFFER a <b>root</b> shell using credentials"
print colorGold+"</b>-- press any other key to abort"
op = user_input(colorWhite+"||: "+colorGold+"</b>",0,1).lower
if "ylus".indexOf(op) == null then return 0 else return "-"+op
end function
//
_go_time = function(user=null,pass=null,open_it)
if DEBUG then print "debug: go time: "+char(10)+"usr: "+user+" is a: "+typeof(user)+char(10)+"pass: "+pass+" is a: "+typeof(pass)
if not user or not pass or user == "" or pass == "" then return colorGold+"</b>psudo: aborting..."
if typeof(user) != "string" or typeof(pass) != "string" then return colorGold+"</b>psudo: aborting..."
locals.sh = get_shell(user,pass)
if typeof( locals.sh ) == "shell" then
print colorLightBlue+"</b>malp: "+colorGreen+"success</color></b>; new shell sent to "+colorOrange+"BUFFER"
if open_it == 0 then open_it = user_input(colorGreen+"</b>-- view context menu in "+colorOrange+"BUFFER"+CT+"? [y/<b>N</b>] ||: "+colorWhite,0,1)
if open_it == 1 or open_it == "y" or open_it == "Y" then return command.malp("-b",locals.sh) else globals.BUFFER.push(locals.sh)
colorGold+"</b>psudo: returning shell object..."
return locals.sh
else
return colorGold+"</b>psudo: "+colorRed+"</b>failed</color> to obtain shell object"+char(10)+colorGold+"</b>-- check credentials and try again"
end if
end function
_shell_prompt = function(shl,c=0)
if typeof(shl) != "shell" then return colorGold+"psudo: error, expected shell, got: "+shl
if typeof(c) == "shell" then
print "psudo: starting_terminal on target shell..."
return shl.start_terminal
end if
if user_input(colorGold+"</b>psudo: "+colorOrange+"warning; start_terminal ends the script!"+char(10)+
colorGold+"psudo: "+colorOrange+"warning; start_terminal may result in an active trace"+char(10)+
colorGold+"</b>Continue? ["+colorWhite+"y"+CT+colorGold+"</b>/"+CT+colorWhite+"N"+CT+colorGold+"</b>] ||: "+colorWhite,0,1).lower == "y" then
//get_custom_object.return_value = "#!#CASCADE#!#"
print "psudo: starting_terminal on active shell..."
print shl.start_terminal
return command.cob("reset")
else
return colorGold+"</b>psudo: aborting..."
end if
end function
if not operation then operation = _psudo_menu
if not operation then return colorGold+"</b>psudo: aborting..."
// if it's a shell we warn and confirm
use_shl = globals.shell
if typeof(operation) == "shell" then use_shl = operation
if typeof(arg2) == "shell" then
use_shl = arg2
operation = arg2
end if
// otherwise we parse the flag or return if invalid flag
if typeof(operation) != "string" and typeof(operation) != "shell" then return colorGold+"</b>psudo: aborting..."
if operation == "-l" or operation == "-y" or typeof(operation) == "shell" then return _shell_prompt(use_shl,operation)
usr = null
psw = null
if operation == "-u" then
if not arg2 then usr = user_input("user name:> ") else usr = arg2
if arg3 then psw = arg3 else psw = user_input("user passwor:> ",1)
return _go_time(usr,psw)
end if
if operation == "-s" or operation == "-f" or operation == "-n" then
conf = 0
if operation == "-f" then conf = 1
if operation == "-n" then conf = -1
usr = "root"
if not arg2 then psw = user_input("root password:> ",1) else psw = arg2
return _go_time(usr,psw,conf)
end if
return colorGold+"</b>psudo: invalid input"+char(10)+"-- aborting..."
end function
command.ls = function(arg1, arg2, arg3=0, arg4=0)
if arg1 == "-h" or arg1 == "help" then return "List Files | List Folders | File Details"+char(10)+
"Usage: ls [opt: -l|-a|-s|-r] [opt: /path] -- list files in path"+char(10)+
"Opt: [-l] -- list all file details for given path"+char(10)+
"Opt: [-a] -- list all files, alphabetically, for given path"+char(10)+
"-- by default files and folders are listed from first created"+char(10)+
"---- to last created "+char(10)+
"Opt: [-s] -- list all files by size (not yet implemented)"+char(10)+
"Opt: [-r] -- list all files and return raw, uncolorized output"+char(10)+
"Note: option flags may be combined in any order"+char(10)+
"-- eg: <b>ls -lars"
subFiles = null
folderPath = globals.currentPath
if DEBUG then print("ls: "+folderPath)
raw_output = false
showHide = 1
showDetails = 0
a_order = 0
s_order = 0
if arg1 then
if arg1.indexOf("-") == 0 then
if arg2 then folderPath = arg2
if arg1.indexOf("l") != null then showDetails = 1
if arg1.indexOf("a") != null then a_order = 1
if arg1.indexOf("s") != null then s_order = 1
if arg1.indexOf("r") != null then raw_output = true
else
folderPath = arg1
end if
end if
folder = globals.get_file(folderPath)
if not folder then return "ls: No such file or directory"
if DEBUG then print("folder: "+folder.path+" is a: "+typeof(folder))
if folder.is_folder then
subFiles = folder.get_folders + folder.get_files
if DEBUG then print "debug: pre alpha sort"
if a_order then
f_buf = []
s_buf = []
for sub in subFiles
f_buf.push(sub.name)
end for
f_buf.sort
for f in f_buf
for sub in subFiles
if sub.name == f then s_buf.push(sub)
end for
end for
subFiles = s_buf
end if
if DEBUG then print "debug: pre size sort"+char(10)+
"-- subFiles: "+subFiles
else
subFiles = [folder]
end if
output = ""
for subFile in subFiles
line_color = colorWhite+"</b>"
nameFile = subFile.name
permission = subFile.permissions
owner = subFile.owner
size = subFile.size
group = subFile.group
is_bin = subFile.is_binary
if is_bin then line_color = colorCyan + "</b>"
if subFile.is_folder then line_color = colorLightBlue + "</b>"
if subFile.is_symlink then nameFile = colorGold+"</b>"+nameFile
if raw_output then line_color = ""
if showDetails then
output = output + char(10) + line_color + permission + " " + owner + " " + group + " "+ size + " bin["+is_bin+"] " + nameFile
else
output = output + char(10) + line_color + nameFile
end if
end for
output = output.trim
output = output.split(char(10))
return format_columns(output.join(char(10)).trim)
end function
command.cd = function(arg1,arg2,arg3,arg4)
if arg1 == "help" or arg1 == "-h" then return "Usage: <b>cd [path|file_object]</b> -- change current working directory to path"+char(10)+
"Usage: <b>cd ..</b> -- go back to parent directory."+char(10)+
"Usage: <b>cd</b> -- return to home directory."+char(10)+
"note: all modes return string on failure; <b>null</b> on success"
if arg1 and typeof(arg1) != "string" and typeof(arg1) != "file" then return "cd: invalid input; expects string or file_object"
if DEBUG then print "debug: cd:"+char(10)+"-- currentPath: "+currentPath+char(10)+"-- current_path: "+current_path
new_path = get_file("/")
if not globals.get_file(globals.currentPath) then globals.currentPath = "/"
if arg1 == "" then arg1 = 0
if not arg1 then
if GLASSPOOL then
new_path = "/"+checkUser(localmachine)
if new_path != "/root" then new_path = "/home"+new_path
arg1 = new_path
new_path = get_file(new_path)
else
arg1 = home_dir
new_path = get_file(arg1)
end if
else if arg1 == ".." then
new_path = get_file(currentPath)
if new_path and new_path.path != "/" then new_path = new_path.parent
else
new_path = get_file(arg1) // handles strings and file objects
end if
if typeof(new_path) != "file" then
res = "cd: "+arg1+" not found"
if arg1 then return res
print res+char(10)+"-- defaulting to <b>/"
new_path = get_file("/")
end if
if not new_path.is_folder then return "cd: "+new_path.path+" is not a directory"
new_path = new_path.path
globals.currentPath = new_path
if GLASSPOOL then return
return cd(globals.currentPath)
end function
// command.cd = function(arg1, arg2, arg3=0, arg4=0)
// if arg1 == "help" or arg1 == "-h" then return "Usage: cd [path] -- change current working directory to path"+char(10)+
// "Usage: cd .. -- go back to parent directory."+char(10)+
// "Usage: cd -- return to home directory."+char(10)+
// "Returns: returns string on failure; empty string on success"
// if arg1 == "" then arg1 = 0
// if not globals.get_file(globals.currentPath) then
// globals.currentPath = home_dir
// if globals.GLASSPOOL then return
// return cd(globals.currentPath)
// end if
// chd = localmachine.File(globals.currentPath)
// if not arg1 then
// globals.currentPath = globals.homePath
// if globals.GLASSPOOL then return
// return cd(globals.currentPath)
// end if
// if not chd then
// globals.currentPath = "/"
// print "cd: path error; setting current path to<b> / </b>"+char(10)+"...please try again"
// if globals.GLASSPOOL then return
// return cd(globals.currentPath)
// end if
// if arg1 == ".." then
// if chd.name != "/" then
// globals.currentPath = chd.parent.path
// if globals.GLASSPOOL then return
// return cd(globals.currentPath)
// end if
// return null
// end if
// new_path = globals.get_file(arg1)
// if new_path then
// if new_path.is_folder then
// globals.currentPath = new_path.path
// if globals.GLASSPOOL then return
// return cd(globals.currentPath)
// else
// return "cd: "+new_path.path+" is not a directory"
// end if
// else
// return "cd: "+arg1+" not found."
// end if
// return null
// end function
command.rm = function(arg1, arg2, arg3=0, arg4=0)
if arg1 == 0 or arg1 == "-h" or arg1 == "help" then return "<b><u>Remove File || RM || Delete</b></u> "+char(10)+"Usage: rm [opt:-r] [path|file_object] [opt:shell|computer]"+char(10)+"Usage: rm [path|file_object] - deletes a file"+char(10)+"Usage: rm -r [path|file_object] - deletes a folder (and all contents)"+char(10)+"Usage: rm [opt:-r] [/absolute/path] [shell_object|computer_object]"+char(10)+"-- uses supplied shell or computer to delete file or folder at path"+char(10)+char(10)+"N.B. The system.log delete entry will be from the originating IP"+char(10)+"-- NOT the ip of the remote shell or computer"+char(10)+"-- be sure to clean the log when remote deleting"
path_to_delete = null
recursive = false
remote = false
shell_to_use = globals.shell
file = null
usage = "rm: usage:<b> rm [opt:-r] [path|file_object] [opt:shell|computer]</b>"
print "<u>"+colorRed+"- - - - - "
if arg1 == "-r" then
recursive = true
arg1 = arg2
arg2 = arg3
end if
if not arg1 then return usage
if typeof(arg1) == "string" then
path_to_delete = arg1
file = globals.get_file(path_to_delete)
end if
if typeof(arg1) == "file" then
file = arg1
path_to_delete = file.path
end if
if typeof(arg1) == "shell" or typeof(arg1) == "computer" then return usage
if not path_to_delete then return usage
if arg2 and typeof(arg2) == "shell" then
shell_to_use = arg2
remote = true
file = shell_to_use.host_computer.File(path_to_delete)
if not file then return "rm: file not found on remote shell." else print "rm: found file on remote shell..."
end if
if arg2 and typeof(arg2) == "computer" then file = arg2.File(path_to_delete)
if file then
if not file.has_permission("w") then return "rm: permission denied"
print "rm: "+colorWhite+"deleting: </b><u>"+file.path
if file.is_folder then
if recursive == true then return file.delete else return "rm: use<b> rm -r [path|file_object] </b>to remove a folder."
end if
return file.delete
end if
return "rm: file not found."
end function
command.mv = function(arg1, arg2=0, arg3=0, arg4=0)
if arg1 == "-h" or arg1 == "help" then return "MOVE || MV || rename || I like to move it move it"+char(10)+
"Usage:"+colorWhite+" mv [opt:-r] [source_path|file_object] [destination_path|file_object]"+char(10)+
"-- move file or folder to new path"+char(10)+
"-- optionally rename the file"+char(10)+
"-- if destination is folder uses original filename, else renames"+char(10)+
"-- overwrites destination file if it exists and is not a folder"+char(10)+
"-- passing the [-r] flag will result in <b>overwriting the destination folder"+char(10)+
"-- if file objects are supplied then uses the object's path"+char(10)+
"-- e.g:<b> mv bob /burger -- moves bob to / dir and renames to burger"+char(10)+
"---- if /burger is a directory; moves bob into burger as /burger/bob"+char(10)+
"-- if bob is already a folder at the destination, and the [-r] flag is passed: "+char(10)+
"---- /burger/bob will be overwritten, otherwise the result is /burger/bob/bob"+char(10)+
" "+char(10)+
"Usage: mv [opt:-r] [source_path|file_object] [@]"+char(10)+
" -- move file to current path using original file name"+char(10)+
" ---- otherwise works as above"+char(10)+
"NOTE: this command moves files between folders on the active shell/computer object"+char(10)+
"-- please use <b>scpm</b> or BUFFER <b>scp</b> to transfer files between remote machines"+char(10)
ow_fldr = false
if arg1 == "-r" then
ow_fldr = true
arg1 = arg2
arg2 = arg3
arg3 = arg4
end if
if not arg1 or not arg2 then return "mv: not enough input"
if typeof(arg1) != "string" and typeof(arg1) != "file" then return "mv: invalid parameters;"+char(10)+
"-- expects strings or file objects"
if typeof(arg2) != "string" and typeof(arg2) != "file" then return "mv: invalid parameters;"+char(10)+
"-- expects strings or file objects"
print "<u>"+colorLightBlue+"= = = = ="
if typeof(arg1) == "file" then
if p_validate(arg1,"size") then file = arg1 else return "mv: error: input file object does not exist"
else
file = globals.get_file(arg1)
end if
if not file then return("mv: can't find " + arg1)
destination = null
final_name = null
if typeof(arg2) == "file" then
if p_validate(arg2,"size") then dest = arg2 else return "mv: error: output file object does not exist"+char(10)+
"-- please purge this object, recreate the file, or supply a string instead"
else
dest = globals.get_file(arg2)
end if
if not dest then
if typeof(arg2) == "string" then
split = arg2.split("/")
final_name = split.pop
else
return "mv: invalid parameters"
end if
if DEBUG then print("mv_split: "+split)
if split.len and split[0] == "" then dest = globals.get_file(split.join("/")) else dest = globals.get_file(split.join("/"))
if DEBUG then print("dest: ["+dest+"]")
if not dest then
if arg2[0] == "/" then destination = "/" else destination = currentPath
else
destination = dest.path
end if
else
if dest.is_folder and not ow_fldr then
destination = dest.path
final_name = file.name
if dest.path == file.path then destination = dest.parent.path
else
destination = dest.parent.path
final_name = dest.name
end if
end if
if final_name == "@" then final_name = file.name
//if destination == "/" then print "mv: "+file.path+" -> "+destination+final_name+"..." else print "mv: <u>"+colorWhite+file.path+" -> "+destination+"/"+final_name+"..."
slash = "/"
if destination == "/" then slash = ""
print "mv: <u>"+colorWhite+file.path+" -> "+destination+slash+final_name
return file.move( destination, final_name )
end function
command.cp = function(arg1, arg2=0, arg3=0, arg4=0)
if arg1 == 0 or arg2 == 0 or arg1 == "-h" or arg1 == "help" then return "COPY || copy files || CP"+char(10)+
"Usage: cp [/old_path] [/new_path] -- copy file or folder to new_path "+char(10)+
"Usage: cp [/old_path] [@] -- copy old path to current path and use original file name"+char(10)+
"Usage: cp [/old/path] [/newpath/newname] -- make a copy of a file with a new name/path"+char(10)+
"Usage Example:"+char(10)+
"-- cp /root/file.txt @ "+char(10)+
"---- copies file.txt to the current directory with name: file.txt"+char(10)+
"Usage Example:"+char(10)+
"-- poke /root/haha | | poke /root/heehee | | cp /root/haha /root/heehee"+char(10)+
"---- creates files haha and heehee then copies haha over heehee, overwriting heehee"+char(10)+
"Usage Example:"+char(10)+
"-- poke haha | | grep -p syst / | cp haha"+char(10)+
"---- create file haha, grep for (system.log) and return file_path, overwrite /var/system.log with haha"
print "<u>"+colorGreen+"= = = = ="
file = null
if typeof(arg1) == "file" then file = arg1 else file = globals.get_file(arg1)
if not file then return("cp: can't find " + arg1)
destination = null
final_name = null
dest = globals.get_file(arg2)
if not dest then
if typeof(arg2) != "string" or arg2.trim == "" then return "cp: invalid destination"
asplit = arg2.split("/")
final_name = asplit.pop
if DEBUG then print("split: "+asplit)
if asplit.len and asplit[0] == "" then dest = globals.get_file(asplit.join("/")) else dest = globals.get_file(asplit.join("/"))
if DEBUG then print("dest: ["+dest+"]")
if not dest then
if arg2[0] == "/" then destination = "/" else destination = currentPath
else
destination = dest.path
end if
else
if dest.is_folder then
destination = dest.path
final_name = file.name
else
destination = dest.parent.path
final_name = dest.name
end if
end if
if final_name == "@" then final_name = file.name
if destination == "/" then print "cp: "+file.path+" => "+destination+final_name else print "cp: <u>"+colorWhite+file.path+" => "+destination+"/"+final_name+"..."
print colorGold+"- - - - - - - - - - - - - - - - - - - - - - -"
return file.copy( destination, final_name )
end function
command.usr = function(arg1, arg2, arg3=0, arg4=0)
if not arg1 or arg1 == "-h" or arg1 == "help" then return "USR || ADD USER || CHOWN"+char(10)+
"Usage: usr [opt: -r] [user] [path] -- asign ownership of file at path to user"+char(10)+
"-- the -r flag applies user ownership recursively"+char(10)+
"Usage: usr [-a|add] [opt:user] [opt:password] -- add a user to the system"+char(10)+
"-- omitting user and or password will result in a prompt for these values"+char(10)+
"Usage: usr [-d|del] [username] [opt:bool 1|0] -- delete a user from the system"+char(10)+
"-- 0 == do not delete the home folder"+char(10)+
"-- 1 == delete the home folder"+char(10)+
"-- any other value results in a prompt"+char(10)+
"Usage: usr -u [path] -- return owner of file at path"+char(10)+
"NOTE: It is good practice to run:"+char(10)+
"|><b> usr -r root / | grp -r root / | rm /etc/passwd | lock </b>"+char(10)+
"-- for optimal security <u><b>on a rented server"+char(10)+
"<size=75%>NOTE: for your peace of mind please use "+colorCyan+"lock"+CT+" and "+colorGreen+" kore -s "+char(10)+
"<size=75%>-- to secure your "+colorGold+"main home"+CT+" pc as"+char(10)+
"<size=75%>-- this ensures you will not brick your system"+char(10)+
"<size=75%>---- however if you somehow get Xorg to be removed from .show_procs, it will fail!!!"
is_recursive = false
if arg1 == "add" or arg1 == "-a" then
if not arg2 then arg2 = user_input("new_user:> ")
if not arg3 then arg3 = user_input(arg2+" password:> ")
if arg2 == "" then return "usr: aborting..."
print "usr: attempting to create user:<b> "+arg2
uc = localmachine.create_user(arg2, arg3)
if uc == 1 then return "-- user created" else return uc
end if
if arg1 == "del" or arg1 == "-d" then
d_user = null
if not arg2 then d_user = user_input("del_user:> ") else d_user = arg2
del_home = null
if arg3 == "0" then del_home = false
if arg3 == "1" then del_home = true
if del_home == null then
del_home = user_input("Delete /home/"+d_user+"? [Y/n] "+char(10)+"||: ",0,1)
if del_home == "n" then del_home = false else del_home = true
end if
ud = localmachine.delete_user(d_user, del_home)
if ud == 1 then return "usr: deleted user: "+d_user else return ud
end if
if arg1.lower == "-r" then
arg1 = 1
end if
if typeof(arg1) == "string" then
if not arg2 then
check_u = globals.get_file(arg1)
if typeof(check_u) == "file" then return check_u.owner
end if
end if
if arg1 == 1 then
if not arg3 then return "usr: invalid arguments. please supply a path."
t_f = globals.get_file(arg3)
if t_f then return t_f.set_owner(arg2, 1) else return "usr: "+arg3+" not found."
else
if not arg2 then return "usr: "+arg1+" not found <b>or</b> path not supplied."
t_f = localmachine.File(arg2)
if t_f then return t_f.set_owner(arg1, 0) else return "usr: "+arg2+" not found."
end if
return null
end function
command.grp = function(arg1, arg2, arg3=0, arg4=0)
if not arg1 or arg1 == "-h" or arg1 == "help" then return "<u>GROUP || ADD GROUP || CHGRP</u>"+char(10)+
"Usage: grp [add|del] [group] [user] -- add or remove group to|from user"+char(10)+
"-- users may multiple groups assigned to them"+char(10)+
"Usage: grp -u [user] -- returns groups associated with user"+char(10)+
"Usage: grp -f [path] -- returns group associated with file at path"+char(10)+
"Usage: grp [opt:-r] [group] [path] -- set group of file at path"+char(10)+
"-- the -r flag applies the group recursively"+char(10)+
"-- each file may have only one group"+char(10)+
"NOTE: It is good practice to run:"+char(10)+
"|><b> usr -r root / | grp -r root / | rm /etc/passwd | lock </b>"+char(10)+
"-- for optimal security <u><b>on a rented server"+char(10)+
"<size=75%>NOTE: for your peace of mind please use "+colorCyan+"lock"+CT+" and "+colorGreen+" kore -s "+char(10)+
"<size=75%>-- to secure your "+colorGold+"main home"+CT+" pc as"+char(10)+
"<size=75%>-- this ensures you will not brick your system"+char(10)+
"<size=75%>---- however if you somehow get Xorg to be removed from .show_procs, it will fail!!!"
is_recursive = false
if arg1 == "-f" then
if not arg2 or arg2 == "" then return "Usage: grp -f [path]"
f_t = globals.get_file(arg2)
if not f_t then return "grp: "+arg2+" not found."
return f_t.group
end if
if arg1 == "-u" then
if not arg2 or arg2 == "" then return "Usage: grp -u [user]"
return globals.localmachine.groups(arg2)
end if
if arg1 == "add" then
if not arg2 or not arg3 then return "Usage: grp add [group] [user]"
return localmachine.create_group(arg3, arg2)
end if
if arg1 == "del" then
if not arg2 or not arg3 then return "Usage: grp del [group] [user]"
return localmachine.delete_group(arg3, arg2)