Skip to content

Instantly share code, notes, and snippets.

@mikesmullin
Last active February 13, 2021 23:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikesmullin/d0d1aa58602f590731ba3ebdc0a33bd7 to your computer and use it in GitHub Desktop.
Save mikesmullin/d0d1aa58602f590731ba3ebdc0a33bd7 to your computer and use it in GitHub Desktop.
ctf wargame beacon.asm Windows 32-bit Winsock API (static; no dependencies) 2,560 bytes
; compile with MASM32
; C:\masm32\bin\ml /c /Zd /coff beacon.asm
; C:\masm32\bin\Link /SUBSYSTEM:WINDOWS beacon.obj
; beacon.exe
;
.386
.model flat, stdcall
option casemap :none
include C:\masm32\include\windows.inc
include C:\masm32\include\kernel32.inc
include C:\masm32\include\user32.inc
includelib C:\masm32\lib\kernel32.lib
includelib C:\masm32\lib\user32.lib
include C:\masm32\include\ws2_32.inc
includelib C:\masm32\lib\ws2_32.lib
.data
uuid db "6220260a-0d5e-4290-89ac-c2d8d68c57a3", 0
hSock dd ?
_addr4 sockaddr_in <?>
wsadata WSADATA <?>
.code
start:
mov _addr4.sin_family, AF_INET
mov _addr4.sin_port, 7017h ; 6000
mov _addr4.sin_addr, 0100007fh ; 127.0.0.1
invoke WSAStartup, 202h, addr wsadata
invoke socket, PF_INET, SOCK_STREAM, IPPROTO_TCP
mov hSock, eax
invoke connect, hSock, addr _addr4, sizeof _addr4
invoke send, hSock, addr uuid, sizeof uuid, 0
; invoke closesocket, hSock
_loop:
invoke Beep, 60, 2000
invoke Sleep, 1000
jmp _loop
invoke ExitProcess, 0
end start
@mikesmullin
Copy link
Author

mikesmullin commented Mar 23, 2018

API Monitor v2 is a good tool for debugging win api stuff
the WIN32.HLP is at https://www.modula2.org/win32tutor/references.php

script just needs a few tweaks to customize behavior. probably don't want it to beep in production, and probably want it to close socket and reconnect between loop intervals. can just rearrange and comment/uncomment lines above to achieve desired effect.

some of the include libs may be possibly omitted, may result in even smaller binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment