diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a1ada0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +nkilluser.bas diff --git a/README.md b/README.md index 6fa5d98..f3f07a3 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,25 @@ If no hosts are listed as arguments it will run on all connected hosts, otherwis ### usage ```bash run nremps [host1] [host2] [host3] [...] +``` + +## scp +Copy files from one host to another. +* If file is not an executable it will follow the provided uupath to the destination and write the file (faster than FTP) +* You can: + * Copy file to each remote host in provided uupath + * Dial a host directly and manually copy the file via ftp (iptun required) + +### usage +```bash +run scp [host1] [host2] [host3] [...] +``` + +## path2arg +Convert a uupath to arguments (replace bangs with spaces). +* Optionally if the first argument is a command, run it with the rest of the arguments. + +### usage +```bash +path2arg.bas [command] ``` \ No newline at end of file diff --git a/nlogin.bas b/nlogin.bas index baeeeb8..423860e 100644 --- a/nlogin.bas +++ b/nlogin.bas @@ -1,25 +1,36 @@ + INFTP=0 + COPYPROGS$="porthack.exe" 1 LASTHOST$ = TH_SED$(TH_HOSTNAME$,"\s.*","") 10 FOR I = 1 TO ARGC%-1 LASTHOST$ = TH_SED$(TH_HOSTNAME$,"\s.*","") + PRINT "Trying " + ARGV$(I) + " ("+STR$(I)+"/"+STR$(ARGC%-1)+")..." IF TH_HASLOGIN(ARGV$(I)) = 0 THEN GOSUB 1000 -21 TH_EXEC "rlogin "+ARGV$(I) - IF INSTR(DIR$, "porthack", 0) = -1 THEN GOSUB 2000 -REM print ARGV$(I)+"$ ls" -REM TH_EXEC "ls" -REM PRINT ARGV$(I)+"$" -REM PRINT ARGV$(I)+"$ netstat" -REM TH_EXEC "netstat" -REM PRINT ARGV$(I)+"$" +21 TH_EXEC "rlogin "+ARGV$(I), DUMP$ + GOSUB 2000 30 NEXT I END 1000 PRINT "No login on " + ARGV$(I) - IF INSTR(DIR$, "porthack", 0) = -1 THEN GOSUB 2000 + IF INSTR(DIR$, "porthack", 0) = -1 THEN GOSUB 2000 : REM Download porthack TH_EXEC("porthack " + ARGV$(I)) RETURN -2000 PRINT "Porthack not on " + TH_HOSTNAME$ + ". Trying to fetch it from " + LASTHOST$ - TH_EXEC("ftp " + LASTHOST$) - TH_EXEC("get porthack.exe") - TH_EXEC("quit") +2000 FOR P=1 TO TH_RE(COPYPROGS$,"[\w.]+",1) + prog$=TH_RE$(COPYPROGS$,"[\w.]+",P) + IF INSTR(DIR$, prog$, 0) = -1 THEN GOSUB 2500 + NEXT P + IF INFTP = 1 THEN GOSUB 3100 RETURN + +2500 PRINT prog$+" not on " + TH_HOSTNAME$ + ". Trying to fetch it from " + LASTHOST$ + IF INFTP = 0 GOSUB 3000 + TH_EXEC "get " + prog$ + RETURN + +3000 TH_EXEC "ftp " + LASTHOST$ + INFTP=1 + RETURN + +3100 TH_EXEC "quit" + INFTP=0 + RETURN \ No newline at end of file diff --git a/path2arg.bas b/path2arg.bas new file mode 100644 index 0000000..eba5b2f --- /dev/null +++ b/path2arg.bas @@ -0,0 +1,15 @@ +REM Convert a uupath to arguments (replace bangs with spaces). +REM Optionally if the first argument is a command, run it with the rest of the arguments. +REM Usage: path2arg.bas [command] +IF ARGC% < 2 THEN PRINT "Usage: path2arg.bas [command] " : END + +HOSTNAME$=TH_SED$(TH_HOSTNAME$,"\s.*","") +PATH$=TH_SED$(ARG$,HOSTNAME$,"","g") +PATH$=TH_SED$(PATH$,"!"," ","g") +IF ARGV$(1) = "run" THEN GOTO 10 +IF TH_RE(DIR$,"[^w]"+ARGV$(1),0) > 0 THEN GOSUB 10 +PRINT PATH$ +END +10 PRINT "Running "+PATH$ +TH_EXEC PATH$ +END \ No newline at end of file diff --git a/scp.bas b/scp.bas new file mode 100644 index 0000000..e174dc9 --- /dev/null +++ b/scp.bas @@ -0,0 +1,73 @@ + REM Copy a file to a remote host + REM Usage: scp [host] [...] + REM Will login (porthack if needed) to each host and copy the file to the destination + REM File is stored in memory, and written to last host. Avoids ftp delays unless exe + NEEDFTP=0 + IF ARGC% < 2 THEN PRINT "Usage: scp [host] [...]" : END + FILENAME$=ARGV$(1) + IF INSTR(FILENAME$, "exe", 0) > 0 THEN NEEDFTP=1 + IF NEEDFTP=1 THEN GOSUB 6000 + IF NEEDFTP = 0 GOSUB 4000 : REM Read File + +1 LASTHOST$ = TH_SED$(TH_HOSTNAME$,"\s.*","") +10 FOR I = 2 TO ARGC%-1 + LASTHOST$ = TH_SED$(TH_HOSTNAME$,"\s.*","") + IF TH_HASLOGIN(ARGV$(I)) = 0 THEN GOSUB 1000 + PRINT "Trying " + ARGV$(I) + " ("+STR$(I-1)+"/"+STR$(ARGC%-2)+")..." +21 TH_EXEC "rlogin "+ARGV$(I), DUMP$ + IF NEEDFTP = 1 THEN GOSUB 2000 +30 NEXT I + IF NEEDFTP = 0 THEN GOSUB 5000 +END + +1000 PRINT "No login on " + ARGV$(I) + IF INSTR(DIR$, "porthack", 0) = -1 THEN GOSUB 2000 + TH_EXEC("porthack " + ARGV$(I)) + RETURN + +2000 IF INSTR(DIR$, FILENAME$, 0) = -1 THEN GOSUB 2500 + PRINT "File already on " + TH_HOSTNAME$ + RETURN + +2500 PRINT FILENAME$+" not on " + TH_HOSTNAME$ + ". Trying to fetch it from " + LASTHOST$ + TH_EXEC "ftp " + LASTHOST$, DUMP$ + TH_EXEC "get " + FILENAME$ + TH_EXEC "quit", DUMP$ + RETURN + +4000 REM Read File + CONTENT$="" + OPEN(FILENAME$), AS #1 +4010 IF EOF(1) THEN GOTO 4020 + INPUT# 1, L$ + CONTENT$=CONTENT$+L$+CHR$(13)+CHR$(10) + GOTO 4010 +4020 CLOSE #1 + RETURN + +5000 REM Sub Write File + PRINT "Writing file " + FILENAME$ + OPEN(FILENAME$), AS #1 + PRINT# 1, CONTENT$ + CLOSE #1 + RETURN + +6000 PRINT "EXE File- Requires FTP." + PRINT "Options:" + PRINT " r) rlogin to each host" + PRINT " d) dial remote host (no auto ftp)" + PRINT " q) quit" +6001 PRINT "Continue? (r/d/q)" + CONT$ = INKEY$ + IF CONT$ = "r" OR CONT$ = "R" THEN RETURN + IF CONT$ = "q" OR CONT$ = "Q" THEN PRINT "Canceling Transfer" : END + IF CONT$ = "d" OR CONT$ = "D" THEN GOTO 8000 + GOTO 6001 + +8000 PRINT "Dialing remote host" + HOST$=ARGV$(ARGC%-1) + TH_EXEC "uumap " + HOST$ + " | grep '#T'", RPHONE$ + PHONE$ = TH_SED$(RPHONE$, ".*#T\s+(\d+).*", "\1") + PRINT "Dialing " + PHONE$ + TH_EXEC "dial " + PHONE$ + END \ No newline at end of file