commit 3b58a05e5eef5b0d25f10a9475006415ba399554 Author: xoy Date: Sun Dec 31 16:55:13 2023 +0100 [First commit] - Create git structure - Adding scripts, tools and classes already written diff --git a/Classes/README.MD b/Classes/README.MD new file mode 100644 index 0000000..c5f680c --- /dev/null +++ b/Classes/README.MD @@ -0,0 +1,17 @@ +# Classes + +## [nmap](https://git.ctdo.de/xoy/xoy_greyhack_src/src/branch/main/Classes/nmap.src) + +The default nmap script as a class. + +### Functions + +#### scan + +- Arguments: *ipAddress* +- Description: *scan an ip address for ports and return the data as an object.* + +#### print + +- Arguments: *data* +- Decription: *printing the data object got by the **scan** function.* \ No newline at end of file diff --git a/Classes/nmap.src b/Classes/nmap.src new file mode 100644 index 0000000..8572b5e --- /dev/null +++ b/Classes/nmap.src @@ -0,0 +1,59 @@ +NMAP = {} + +NMAP.scan = function( ipAddress ) + if is_valid_ip( ipAddress ) and get_shell.host_computer.is_network_active then + DATA = {} + DATA.dateOfScan = current_date + DATA.ipAddress = ipAddress + DATA.isLanIp = is_lan_ip( DATA.ipAddress ) + + //check if ipAddress is local and set the router var + if DATA.isLanIp then DATA.router = get_router else DATA.router = get_router( ipAddress ) + //break and return false if the ip address was not found + if DATA.router == null then return false + + //define raw port list var + raw_ports = null + + //check if local and set raw port list + if not DATA.isLanIp then raw_ports = DATA.router.used_ports else raw_ports = DATA.router.device_ports(DATA.ipAddress) + //break and return false if the ip address was not found + if raw_ports == null then return false + + //define port list var + DATA.ports = [] + + //fill port list + for port in raw_ports + serviceInfo = DATA.router.port_info(port) + lanIp = port.get_lan_ip + if port.is_closed and not DATA.isLanIp then portStatus = "open" else portStatus = "closed" + + INFO = { + "portNumber": port.port_number, + "serviceInfo": serviceInfo, + "lanIp": lanIp, + "status": portStatus} + + DATA.ports = DATA.ports + [INFO] + end for + + return DATA + else + return false + end if +end function + +NMAP.print = function( data ) + info = "PORT STATE SERVICE VERSION LAN" + print("\nPrinting nmap scan from " + data.dateOfScan) + print("Interesting ports on " + data.ipAddress + "\n") + if data.ports.len == 0 then + print("No open ports.") + else + for port in data.ports + info = info + "\n" + port.portNumber + " " + port.status + " " + port.serviceInfo + " " + port.lanIp + end for + print(format_columns(info) + "\n") + end if +end function \ No newline at end of file diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..e8a3062 --- /dev/null +++ b/README.MD @@ -0,0 +1,13 @@ +# xoy grey hack sources + +## [Scripts](https://git.ctdo.de/xoy/xoy_greyhack_src/src/branch/main/Scripts) + +Little scipts that do stuff without additional sources. + +## [Tools](https://git.ctdo.de/xoy/xoy_greyhack_src/src/branch/main/Tools) + +Scripts that require additional sources. + +## [Classes](https://git.ctdo.de/xoy/xoy_greyhack_src/src/branch/main/Classes) + +Classes for the tools. \ No newline at end of file diff --git a/Scripts/BeRightBack.src b/Scripts/BeRightBack.src new file mode 100644 index 0000000..f5ebff2 --- /dev/null +++ b/Scripts/BeRightBack.src @@ -0,0 +1,12 @@ +message = "be right back" +i = 1 +while(true) + clear_screen + print message + "." * i + wait(0.5) + if i < 3 then + i = i + 1 + else + i = 1 + end if +end while diff --git a/Scripts/README.MD b/Scripts/README.MD new file mode 100644 index 0000000..713e111 --- /dev/null +++ b/Scripts/README.MD @@ -0,0 +1,5 @@ +# Scripts + +## [BeRightBack](https://git.ctdo.de/xoy/xoy_greyhack_src/src/branch/main/Scripts/BeRightBack.src) + +Just a hello world thingy. \ No newline at end of file diff --git a/Tools/README.MD b/Tools/README.MD new file mode 100644 index 0000000..3e49d31 --- /dev/null +++ b/Tools/README.MD @@ -0,0 +1,11 @@ +# Tools + +## [ipinfo](https://git.ctdo.de/xoy/xoy_greyhack_src/src/branch/main/Tools/ipinfo.src) + +Get information about an ip address. + +Usage: *ipinfo [ip address]* + +### Requirements + +- [nmap](https://git.ctdo.de/xoy/xoy_greyhack_src/src/branch/main/Classes/nmap.src) \ No newline at end of file diff --git a/Tools/ipinfo.src b/Tools/ipinfo.src new file mode 100644 index 0000000..dd9e7e5 --- /dev/null +++ b/Tools/ipinfo.src @@ -0,0 +1,17 @@ +if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit("Usage: ipinfo [ip address]\nExample: ipinfo 127.0.0.1") +if not is_valid_ip(params[0]) then exit("ipinfo: invalid ip address") +if not get_shell.host_computer.is_network_active then exit("ipinfo: No internet access.") + +ipAddress = params[0] + +import_code("/src/nmap.src") + +admin = null + +if not is_lan_ip(ipAddress) then admin = whois(ipAddress) + +data = NMAP.scan(ipAddress) +if data == false then exit("Error while scanning (check the ip address)!") + +if not admin == null then print(admin) else print("No admin data on local addresses!") +NMAP.print(data) \ No newline at end of file