Zireael |
Отправлено: 15 Августа, 2020 - 01:43:59
|
Эксперт
Покинул форум
Сообщений всего: 4465
Дата рег-ции: Нояб. 2017
Репутация: 585
|
Цитата: powershell.exe -command "gwmi -q 'select * from win32_computersystem' | clip"
Так не будет появляться окно командной строки:
CODE:#define STARTF_USESHOWWINDOW 1
#define INFINITE -1
external(INT, "CreateProcess", "CreateProcessA", "Kernel32.dll");
external(INT, "WaitForSingleObject", "WaitForSingleObject", "Kernel32.dll");
external(INT, "CloseHandle", "CloseHandle", "Kernel32.dll");
PS("-command ^"gwmi -q ^'select * from win32_computersystem^' | clip"); //^"
string text;
readclipboard (text);
messagebox(text);
function PS(string CommandLine)
{
int STARTUPINFOA[17], PROCESS_INFORMATION[4];
initialarray(#STARTUPINFOA[0], 0);
STARTUPINFOA[0]=68;
STARTUPINFOA[11]=STARTF_USESHOWWINDOW;
if(CreateProcess(0, "powershell.exe "+CommandLine, 0, 0, 0, 0, 0, 0, address(#STARTUPINFOA[0]), address(#PROCESS_INFORMATION[0])))
{
WaitForSingleObject(PROCESS_INFORMATION[0], INFINITE);
CloseHandle(PROCESS_INFORMATION[0]);
}
} |
|
|
Kibor |
Отправлено: 15 Августа, 2020 - 11:01:21
|
Эксперт
Покинул форум
Сообщений всего: 8217
Дата рег-ции: Март 2013
Откуда: Одесса
Репутация: 357
|
ivantu пишет: Еще бы хоть какой то результат возвращать в кибор научиться из командной строки, было бы 5 звезд ))
Запуск процесса и налаживание Pipe канала с ним
Ниже код который позволяет настраивать Pipe канал по WinApi функциям
CODE:#define STARTF_USESHOWWINDOW 1
#define STARTF_USESTDHANDLES 256
#define SW_HIDE 0
#define INFINITE -1
external(INT, "CreatePipe", "CreatePipe", "kernel32.dll");
external(VOID, "ZeroMemory", "RtlZeroMemory", "kernel32.dll");
external(VOID, "GetStartupInfo", "GetStartupInfoA", "kernel32.dll");
external(INT, "CreateProcess", "CreateProcessA", "kernel32.dll");
external(INT, "ReadFile", "ReadFile", "kernel32.dll");
external(INT, "WriteFile", "WriteFile", "kernel32.dll");
external(INT, "TerminateProcess", "TerminateProcess", "kernel32.dll");
external(INT, "WaitForSingleObject", "WaitForSingleObject", "kernel32.dll");
external(INT, "CloseHandle", "CloseHandle", "kernel32.dll");
string path="C:\Windows\System32\cmd.exe -i";
int hReadPipe1, hWritePipe1, hReadPipe2, hWritePipe2;
char pi[16];
char W_buff[1000000];
string Rez;
if (Start())
{
int lBytesWrite;
WriteFile(hWritePipe2, "help^n", size("help^n"), address(#lBytesWrite), 0);
sleep(500);
int readed;
ReadFile(hReadPipe1, address(#W_buff[0]), 1024 , address(#readed), 0);
W_buff[readed]=0;
messagebox (format(#W_buff[0]));
}
function Start()//Запустить программу и наладить с ней связь PIPE
{
int ret;
//SECURITY_ATTRIBUTES
char sa[12];
initialarray(#sa[0], 0);
writeaddress(sizearray(sa), address(#sa[0]));
writeaddress(0, address(#sa[4]));
writeaddress(1, address(#sa[8]));
ret=CreatePipe(address(#hReadPipe1),address(#hWritePipe1),address(#sa[0]),0);
if (ret==0)return 0;
ret=CreatePipe(address(#hReadPipe2),address(#hWritePipe2),address(#sa[0]),0);
if (ret==0)return 0;
//STARTUPINFO
char si[68];
initialarray(#si[0], 0);
ZeroMemory(address(#si[0]),sizearray(si));
GetStartupInfo(address(#si[0]));
writeaddress(sizearray(si), address(#si[0]));
writeaddress(STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES, address(#si[44]));
writeaddress(SW_HIDE, address(#si[48]));
writeaddress(hReadPipe2, address(#si[56]));
writeaddress(hWritePipe1, address(#si[60]));
writeaddress(hWritePipe1, address(#si[64]));
//PROCESS_INFORMATION
initialarray(#pi[0], 0);
ret=CreateProcess(0,path,0,0,1,0,0,0,address(#si[0]),address(#pi[0]));
if (ret==0)return 0;
return 1;
}
function Close()
{
TerminateProcess(addressi(address(#pi[0])), 0);
WaitForSingleObject(addressi(address(#pi[0])), INFINITE );
CloseHandle(addressi(address(#pi[0])));
CloseHandle(addressi(address(#pi[4])));
CloseHandle(hReadPipe1);
CloseHandle(hWritePipe1);
CloseHandle(hReadPipe2);
CloseHandle(hWritePipe2);
} |
|
|
|