-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLUA_Powershell_HTTPS_GETPOST.lua
86 lines (80 loc) · 2.49 KB
/
LUA_Powershell_HTTPS_GETPOST.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
--21/8/21
function get(link,headers)
headers=headers or nil
local res = {}
local command = '$r=Invoke-WebRequest "'..link..'"'
if headers then
local hd = ' -Headers @{'
for i,v in pairs(headers) do
hd=hd..'"'..i..'"="'..v..'";'
end
command=command..hd:sub(1,-2)..'}'
end
command=command..';$r.statuscode;$r.statusdescription;$r.content'
command='powershell "'..command:gsub('"','\\"')..'"'
local status = io.popen(command):read('*a')
if status~='' then
for i in status:gmatch('[^\n]+') do
if not res['statuscode'] then
res['statuscode']=i
elseif not res['statusdescription'] then
res['statusdescription']=i
else
break
end
end
res['content']=status:sub(#res['statuscode']+#res['statusdescription']+3)
res['statuscode']=tonumber(res['statuscode'])
return res
end
end
function post(url, params)
local res = {}
local command = '$r=Invoke-WebRequest "'..url..'" -Method POST'
local param = ' -Body @{'
for i,v in pairs(params) do
i,v=i:gsub('"',"'"),v:gsub('"',"'")
param=param..'"'..i..'"="'..v..'";'
end
command=command..param:sub(1,-2)..'}'
command=command..';$r.statuscode;$r.statusdescription;$r.content'
command='powershell "'..command:gsub('"','\\"')..'"'
local status = io.popen(command):read('*a')
if status~='' then
for i in status:gmatch('[^\n]+') do
if not res['statuscode'] then
res['statuscode']=i
elseif not res['statusdescription'] then
res['statusdescription']=i
else
break
end
end
res['content']=status:sub(#res['statuscode']+#res['statusdescription']+3)
res['statuscode']=tonumber(res['statuscode'])
return res
end
end
-- Extra [ Download file from internet ]
function download(link, filename, path)
path=path or nil
if not path then
path='C:\\Users\\'..os.getenv('username')..'\\Downloads\\'
else
if path:sub(#path)~='\\' then
path=path..'\\'
end
end
path=path..filename
res = io.popen('powershell Invoke-WebRequest "'..link..'" -OutFile "'..path..'"'):read('*a')
if res=='' then
return true
end
return false
end
a = get('https://google.com/')
if a then
if a['statuscode'] == 200 then
print(a['content'])
end
end