Last active
December 19, 2015 10:39
-
-
Save jdecaron/5941915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
#include <winsock2.h> | |
int pid = 0; | |
STARTUPINFO lpStartupInfo; | |
PROCESS_INFORMATION lpProcessInformation; | |
BOOL CALLBACK EnumChildWindowsProc(HWND hwnd, LPARAM lparam){ | |
DWORD p; | |
GetWindowThreadProcessId(hwnd, &p); | |
if(pid == p){ | |
FlashWindow((HWND)lparam, FALSE); | |
} | |
return 1; | |
} | |
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lparam){ | |
DWORD p; | |
GetWindowThreadProcessId(hwnd, &p); | |
EnumChildWindows(hwnd, EnumChildWindowsProc, (INT)hwnd); | |
return 1; | |
} | |
int flash(){ | |
char s[256]; | |
FILE *p; | |
p = _popen("C:\\Windows\\System32\\netstat.exe -on", "rt"); | |
for(int i = 0; i < 4; i++){ | |
fgets(s, 256, p); | |
} | |
char s1[16]; | |
char s2[12]; | |
char s3[6]; | |
int ls = 0; | |
while(fgets(s, 256, p) != NULL){ | |
int cc = 0; | |
for(int i = 0; i < strlen(s); i++){ | |
if(s[i] == ' '){ | |
ls = i; | |
}else if(i - ls == 1){ | |
if(cc == 2){ | |
strncpy(s1, &s[i], 15); | |
s1[15] = 0; | |
} | |
else if(cc == 3){ | |
strncpy(s2, &s[i], 11); | |
s2[11] = 0; | |
} | |
else if(cc == 4){ | |
strncpy(s3, &s[i], strlen(s) - i); | |
s3[strlen(s) - (i + 1)] = 0; | |
} | |
cc++; | |
} | |
} | |
if(strcmp("127.0.0.1:50007", s1) == 0 && strcmp("ESTABLISHED", s2) == 0){ | |
pid = atoi(s3); | |
EnumWindows(EnumWindowsProc, 0); | |
} | |
} | |
return 0; | |
} | |
int main(int argc, char **argv){ | |
BOOL sv = FALSE; | |
char b[4096]; | |
int sl = sizeof (BOOL); | |
int r = 0; | |
char *s = "HTTP/1.0 200 OK\r\nContent-Type: image/gif\r\n\r\n\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x00\x00\x00\x2c\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x4c\x01\x00\x3b"; | |
struct sockaddr_in service; | |
service.sin_family = AF_INET; | |
service.sin_addr.s_addr = inet_addr("127.0.0.1"); | |
service.sin_port = htons(50007); | |
WSADATA wsaData; | |
SOCKET a = INVALID_SOCKET; | |
SOCKET listener = INVALID_SOCKET; | |
WSAStartup(MAKEWORD(2, 2), &wsaData); | |
while(1){ | |
listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); | |
r = setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (char *) &sv, sl); | |
bind(listener, (SOCKADDR *) &service, sizeof(service)); | |
listen(listener, 1); | |
a = accept(listener, NULL, NULL); | |
r = recv(a, b, 4096, 0); | |
if(strncmp(b, "GET ", 4) == 0){ | |
flash(); | |
send(a, s, 73, 0); | |
} | |
shutdown(a, 2); shutdown(listener, 2); | |
closesocket(a); closesocket(listener); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tcc.exe lib\wsock32.def lib\user32.def examples\instfls.c