-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathghost.lua
68 lines (52 loc) · 2.16 KB
/
ghost.lua
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
-- Ghost.lua
--[[
Ghost Library
This Lua module provides network-related functions such as ping, WHOIS lookup, traceroute, and HTTP requests.
To use this module, you will need to have the following dependencies installed on your system:
- Curl: https://curl.se/download.html
- Whois: http://www.linux.it/~md/software/
- Traceroute: https://github.com/korczis/traceroute-windows
- LuaSocket (optional, for additional networking functionality): https://github.com/diegonehab/luasocket
Please make sure you have these dependencies installed and added to your system's PATH environment variable before using this module.
Usage:
local Ghost = require("Ghost")
Ghost.ping("8.8.8.8") -- Pings the given IP address
Ghost.whois("google.com") -- Retrieves WHOIS information for the given domain name
Ghost.traceroute("google.com") -- Traces the route packets take to reach the given destination
local response_body = Ghost.http_request("https://example.com") -- Makes an HTTP request to the given URL and returns the response body
Author: @ThatUncreativeDude on GitHub
Version: 1.0.1
--]]
-- Define the Ghost module
local Ghost = {}
-- Define module level constants
Ghost.VERSION = "1.0.1"
-- Ping an IP address and print the response
function Ghost.ping(ip)
local handle = io.popen("ping -n 1 " .. ip)
local result = handle:read("*a")
handle:close()
print(result)
end
-- Retrieve WHOIS information for a domain name or IP address
function Ghost.whois(domain_or_ip)
local handle = io.popen("whois " .. domain_or_ip)
local result = handle:read("*a")
handle:close()
print(result)
end
-- Trace the route packets take to reach a destination
function Ghost.traceroute(destination)
local handle = io.popen("tracert " .. destination)
local result = handle:read("*a")
handle:close()
print(result)
end
-- Make an HTTP request and return the response body
function Ghost.http_request(url)
local handle = io.popen("curl --silent " .. url)
local result = handle:read("*a")
handle:close()
return result
end
return Ghost