|
|
|
Получить содержимое страницы, Готовый скрипт |
|
|
cirus |
13.10.2020, 13:13
|
Elder
Сообщений: 3.480
Регистрация: 18.8.2014 Группа: Пользователи Наличность: 26691
Пользователь №: 16.971
Возраст: 29
|
Пример1
Код --lua local ffi = require("ffi") local inet = ffi.load('Wininet.dll')
local INTERNET_OPEN_TYPE_PRECONFIG = 0 local INTERNET_DEFAULT_HTTPS_PORT = 443 local INTERNET_SERVICE_HTTP = 3 local INTERNET_FLAG_SECURE = 8388608 local INTERNET_FLAG_NO_CACHE_WRITE = 67108864 ffi.cdef[[ int InternetOpenA(const char* lpszAgent, unsigned long dwAccessType, const char* lpszProxy, const char* lpszProxyBypass, unsigned long dwFlags); bool InternetCloseHandle(int hInternet); int InternetConnectA(int hInternet, const char* lpszServerName, unsigned short nServerPort, const char* lpszUserName, const char* lpszPassword, unsigned long dwService, unsigned long dwFlags,unsigned long dwContext); int HttpOpenRequestA(int hConnect, const char* lpszVerb, const char* lpszObjectName, const char* lpszVersion, const char* lpszReferrer, const char* lplpszAcceptTypes, unsigned long dwFlags, unsigned long dwContext); bool HttpSendRequestA(int hRequest, const char* lpszHeaders, unsigned long dwHeadersLength, const char* lpOptional, unsigned long dwOptionalLength); bool InternetReadFile(int hFile, char* lpBuffer, unsigned long dwNumberOfBytesToRead, unsigned long* lpdwNumberOfBytesRead); ]]
function http(Verb, ServerName, ObjectName) local buf = ffi.new('char[9999]') local dwBytesRead = ffi.new('unsigned long[1]') local hInternet = inet.InternetOpenA("Mozilla", INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0) if hInternet then local hConnect = inet.InternetConnectA(hInternet, ServerName, INTERNET_DEFAULT_HTTPS_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0) if hConnect then local hRequest = inet.HttpOpenRequestA(hConnect, Verb, ObjectName, nil, nil, nil, INTERNET_FLAG_SECURE + INTERNET_FLAG_NO_CACHE_WRITE, 0) if hRequest then inet.HttpSendRequestA(hRequest, '', 0, '', 0) local fr='' while inet.InternetReadFile(hRequest, buf, ffi.sizeof(buf)-1, dwBytesRead) do if dwBytesRead[0] == 0 then break end fr = fr .. ffi.string(buf, dwBytesRead[0]) end inet.InternetCloseHandle(hRequest) return fr end inet.InternetCloseHandle(hConnect) end local close = inet.InternetCloseHandle(hInternet) end end
log 'clear' log 'mode compact'
local s = http('POST', 'forum.uokit.com', 'index.php') -- отправка запроса -- в переменной s содержится код страницы forum.uokit.com/index.php
local guest, user, hidden = s:match('%<b%>(%d+)%<%/b%> гостей, %<b%>(%d+)%<%/b%> пользователей %<b%>(%d+)%<%/b%> скрытых пользователей') log('На форуме сейчас:\r\n', guest, 'гостей, ', user, ' пользователей, ', hidden, ' скрытых пользователей\r\n') log('Список пользователей:') for name_user in s:gmatch('title=.%d+:%d+.-([^%>]-)%<%/') do log(name_user) end Пример2
Код --lua local ffi = require("ffi") local inet = ffi.load('Wininet.dll') local shell = ffi.load('Shell32.dll') ffi.cdef[[ int InternetOpenA(const char* lpszAgent, unsigned long dwAccessType, const char* lpszProxy, const char* lpszProxyBypass, unsigned long dwFlags); bool InternetCloseHandle(int hInternet); int InternetConnectA(int hInternet, const char* lpszServerName, unsigned short nServerPort, const char* lpszUserName, const char* lpszPassword, unsigned long dwService, unsigned long dwFlags,unsigned long dwContext); int HttpOpenRequestA(int hConnect, const char* lpszVerb, const char* lpszObjectName, const char* lpszVersion, const char* lpszReferrer, const char* lplpszAcceptTypes, unsigned long dwFlags, unsigned long dwContext); bool HttpSendRequestA(int hRequest, const char* lpszHeaders, unsigned long dwHeadersLength, const char* lpOptional, unsigned long dwOptionalLength); bool InternetReadFile(int hFile, char* lpBuffer, unsigned long dwNumberOfBytesToRead, unsigned long* lpdwNumberOfBytesRead); ]] local INTERNET_OPEN_TYPE_PRECONFIG = 0 local INTERNET_DEFAULT_HTTPS_PORT = 443 local INTERNET_SERVICE_HTTP = 3 local INTERNET_FLAG_SECURE = 8388608 local INTERNET_FLAG_NO_CACHE_WRITE = 67108864
ffi.cdef[[int ShellExecuteA(int hwnd, const char* lpOperation, const char* lpFile, const char* lpParameters, const char* lpDirectory, int nShowCmd);]] local SW_SHOW = 5
function http(Verb, ServerName, ObjectName) local buf = ffi.new('char[9999]') local dwBytesRead = ffi.new('unsigned long[1]') local hInternet = inet.InternetOpenA("Mozilla", INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0) if hInternet then local hConnect = inet.InternetConnectA(hInternet, ServerName, INTERNET_DEFAULT_HTTPS_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0) if hConnect then local hRequest = inet.HttpOpenRequestA(hConnect, Verb, ObjectName, nil, nil, nil, INTERNET_FLAG_SECURE + INTERNET_FLAG_NO_CACHE_WRITE, 0) if hRequest then inet.HttpSendRequestA(hRequest, '', 0, '', 0) local fr='' while inet.InternetReadFile(hRequest, buf, ffi.sizeof(buf)-1, dwBytesRead) do if dwBytesRead[0] == 0 then break end fr = fr .. ffi.string(buf, dwBytesRead[0]) end inet.InternetCloseHandle(hRequest) return fr end inet.InternetCloseHandle(hConnect) end local close = inet.InternetCloseHandle(hInternet) end return nil end
log 'clear' log 'mode compact' local name_function = 'CreateWindowExA' -- получить содержимое страницы https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexa local s = http('POST', 'docs.microsoft.com', [[en-us/windows/win32/api/winuser/nf-winuser-]] .. name_function) if s then local file = io.open([[C:\content.txt]], 'wb') if file then file:write(s) file:close() shell.ShellExecuteA(0, 'open', [[C:\content.txt]], '', '', SW_SHOW) end
-- найти текст между <pre><code class="lang-cpp"> и </code></pre> local parameters = s:match('%<pre%>%<code class%=%"lang%-cpp%"%>(.-)%<%/code%>%<%/pre%>') if parameters then log (parameters) end end Пример3
Код --lua local ffi = require("ffi") local inet = ffi.load('Wininet.dll')
local INTERNET_OPEN_TYPE_PRECONFIG = 0 local INTERNET_DEFAULT_HTTPS_PORT = 443 local INTERNET_SERVICE_HTTP = 3 local INTERNET_FLAG_SECURE = 8388608 local INTERNET_FLAG_NO_CACHE_WRITE = 67108864 ffi.cdef[[ int InternetOpenA(const char* lpszAgent, unsigned long dwAccessType, const char* lpszProxy, const char* lpszProxyBypass, unsigned long dwFlags); bool InternetCloseHandle(int hInternet); int InternetConnectA(int hInternet, const char* lpszServerName, unsigned short nServerPort, const char* lpszUserName, const char* lpszPassword, unsigned long dwService, unsigned long dwFlags,unsigned long dwContext); int HttpOpenRequestA(int hConnect, const char* lpszVerb, const char* lpszObjectName, const char* lpszVersion, const char* lpszReferrer, const char* lplpszAcceptTypes, unsigned long dwFlags, unsigned long dwContext); bool HttpSendRequestA(int hRequest, const char* lpszHeaders, unsigned long dwHeadersLength, const char* lpOptional, unsigned long dwOptionalLength); bool InternetReadFile(int hFile, char* lpBuffer, unsigned long dwNumberOfBytesToRead, unsigned long* lpdwNumberOfBytesRead); ]]
function http(Verb, ServerName, ObjectName) local buf = ffi.new('char[9999]') local dwBytesRead = ffi.new('unsigned long[1]') local hInternet = inet.InternetOpenA("Mozilla", INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0) if hInternet then local hConnect = inet.InternetConnectA(hInternet, ServerName, INTERNET_DEFAULT_HTTPS_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0) if hConnect then local hRequest = inet.HttpOpenRequestA(hConnect, Verb, ObjectName, nil, nil, nil, INTERNET_FLAG_SECURE + INTERNET_FLAG_NO_CACHE_WRITE, 0) if hRequest then inet.HttpSendRequestA(hRequest, '', 0, '', 0) local fr='' while inet.InternetReadFile(hRequest, buf, ffi.sizeof(buf)-1, dwBytesRead) do if dwBytesRead[0] == 0 then break end fr = fr .. ffi.string(buf, dwBytesRead[0]) end inet.InternetCloseHandle(hRequest) return fr end inet.InternetCloseHandle(hConnect) end local close = inet.InternetCloseHandle(hInternet) end end
log 'clear' log 'mode compact' local s = http('GET', 'api.ipify.org', '') -- отправка запроса log (s) s = http('GET', 'api.ipify.org', '?format=json') -- отправка запроса log (s)
|
|
|
|
Fors1k |
13.10.2020, 15:48
|
Journeyman
Сообщений: 497
Регистрация: 19.12.2017 Группа: Пользователи Наличность: 2399
Пользователь №: 18.746
|
--------------------
Для связи
|
|
|
|
neves |
29.10.2020, 3:04
|
Novice
Сообщений: 64
Регистрация: 4.10.2019 Группа: Пользователи Наличность: 0
Пользователь №: 19.419
Возраст: 19
|
How to send request to given IP instead of domain name? for example: Код local s = http('GET', 'mail.ru', ' ') log (s)
This works and prints the whole html of mail.ru. Код local s = http('GET', '94.100.180.70', ' ') log (s)
This sends request to the IP address of mail.ru and doesn't works. This isn't good example, but you can understand what am I trying to say. Server IP may be something like this too: 54.12.142.102:3333, still doesn't works. Edit: Example url: http://97.77.172.242:8088/
|
|
|
|
|
|
2 чел. читают эту тему (гостей: 2, скрытых пользователей: 0)
Пользователей: 0
|
|