├── csharp ├── examples ├── packages │ ├── System.Runtime.InteropServices.RuntimeInformation.4.3.0 │ │ ├── lib │ │ │ ├── MonoAndroid10 │ │ │ │ └── _._ │ │ │ ├── MonoTouch10 │ │ │ │ └── _._ │ │ │ ├── xamarinios10 │ │ │ │ └── _._ │ │ │ ├── xamarinmac20 │ │ │ │ └── _._ │ │ │ ├── xamarintvos10 │ │ │ │ └── _._ │ │ │ ├── xamarinwatchos10 │ │ │ │ └── _._ │ │ │ ├── win8 │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ │ ├── net45 │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ │ ├── wpa81 │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ │ └── netstandard1.1 │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ ├── ref │ │ │ ├── MonoAndroid10 │ │ │ │ └── _._ │ │ │ ├── MonoTouch10 │ │ │ │ └── _._ │ │ │ ├── xamarinios10 │ │ │ │ └── _._ │ │ │ ├── xamarinmac20 │ │ │ │ └── _._ │ │ │ ├── xamarintvos10 │ │ │ │ └── _._ │ │ │ ├── xamarinwatchos10 │ │ │ │ └── _._ │ │ │ └── netstandard1.1 │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ ├── System.Runtime.InteropServices.RuntimeInformation.4.3.0.nupkg │ │ ├── runtimes │ │ │ ├── win │ │ │ │ └── lib │ │ │ │ │ ├── net45 │ │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ │ │ │ ├── netcore50 │ │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ │ │ │ └── netstandard1.1 │ │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ │ ├── aot │ │ │ │ └── lib │ │ │ │ │ └── netcore50 │ │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ │ └── unix │ │ │ │ └── lib │ │ │ │ └── netstandard1.1 │ │ │ │ └── System.Runtime.InteropServices.RuntimeInformation.dll │ │ ├── ThirdPartyNotices.txt │ │ └── dotnet_library_license.txt │ ├── Nancy.1.4.4 │ │ ├── Nancy.1.4.4.nupkg │ │ └── lib │ │ │ └── net40 │ │ │ └── Nancy.dll │ ├── WebSocketSharp.1.0.3-rc11 │ │ ├── lib │ │ │ └── websocket-sharp.dll │ │ └── WebSocketSharp.1.0.3-rc11.nupkg │ └── Nancy.Hosting.Self.1.4.1 │ │ ├── Nancy.Hosting.Self.1.4.1.nupkg │ │ └── lib │ │ └── net40 │ │ └── Nancy.Hosting.Self.dll ├── resources │ ├── r2wars_logo.png │ └── r2wars_logo_transparent.png ├── App.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── packages.config ├── MyEvent.cs ├── Torneo │ ├── PairingsGeneratorState.cs │ ├── copyright.txt │ ├── TournamentTeamScore.cs │ ├── TournamentNameTable.cs │ ├── TournamentTeam.cs │ ├── TournamentPairing.cs │ ├── TournamentRound.cs │ ├── TournamentRanking.cs │ ├── InvalidTournamentStateException.cs │ └── Score.cs ├── lsbots.sh ├── Makefile ├── r2wars.sln ├── MainModule.cs ├── Program.cs ├── CustomBootstrapper.cs ├── r2warsWebSocket.cs ├── clsPipe.cs └── r2wars.csproj ├── vlang ├── Makefile ├── main.v └── r2wars │ └── lib.v ├── python ├── show.jpg ├── t │ ├── pancake.x86-32.asm │ ├── test.x86-32 │ ├── test2.x86-32 │ ├── pancake.gb.asm │ └── pancake.mips-32.asm ├── r2wars.py └── README.md ├── examples ├── pancake.arm-32.asm ├── pancake.x86-32.asm ├── hmht.8051.asm ├── r2con2021 │ ├── final │ │ ├── kamehameha.x86-32.asm │ │ ├── ricardoapl.x86-32.asm │ │ ├── theta.arm-32.asm │ │ ├── zeta.arm-32.asm │ │ ├── newbot.x86-32.asm │ │ ├── amaterasu.x86-32.asm │ │ ├── x3ero0.arm-32.asm │ │ ├── old-flacucho.arm-32.asm │ │ └── amphibia.arm-32.asm │ ├── round1 │ │ ├── ricardoapl.x86-32.asm │ │ ├── x3ero0.x86-64.asm │ │ ├── old-flacucho.arm-32.asm │ │ ├── amphibia.arm-32.asm │ │ ├── 30-09-2021 21-10-04.r2wars.txt │ │ └── 30-09-2021 21-11-53.r2wars.txt │ └── round2 │ │ ├── ricardoapl.x86-32.asm │ │ ├── karma.x86-32.asm │ │ ├── zeta.arm-32.asm │ │ ├── x3ero0.arm-64.asm │ │ ├── x3ero0.x86-64.asm │ │ ├── old-flacucho.arm-32.asm │ │ └── amphibia.arm-32.asm ├── pancake.mips-64.asm ├── jordi.x86-32.asm └── r2con2020 │ ├── round3 │ ├── kurt │ │ └── niku.x86-64.asm │ ├── erfur PhD 1080p │ │ └── kaploombaa.x86-32.asm │ ├── ADAM WEST │ │ └── oldMacaco.x86-32.asm │ ├── karliss │ │ └── karliss.x86-64.asm │ ├── 현수 차 │ │ └── soo.x86-32.asm │ ├── Anirudh │ │ └── icyphox.x86-32.asm │ ├── robin │ │ └── hexrays.x86-32.asm │ ├── Aissen │ │ └── anisse.arm-32.asm │ ├── # │ │ ├── old │ │ │ └── unnamedreplicator.x86-32.asm │ │ └── hayirlisiolsun.x86-32.asm │ ├── Austin Emmitt │ │ └── alkalinear.arm-64.asm │ ├── lars │ │ └── zutle.x86-32.asm │ ├── goyo │ │ ├── flacucho.arm-32.asm │ │ └── gordasco.x86-32.asm │ └── CaptnBanana │ │ └── FATbanana.x86-32.asm │ ├── round4 │ ├── kurt │ │ └── niku.x86-64.asm │ ├── erfur PhD 1080p │ │ └── kaploombaa.x86-32.asm │ ├── karliss │ │ └── karliss.x86-64.asm │ ├── ADAM WEST │ │ └── ThreeHeadedMonkey.x86-32.asm │ ├── Anirudh │ │ └── icyphox.x86-32.asm │ ├── robin │ │ └── hexrays.x86-32.asm │ ├── cyanpencil │ │ ├── cyanpencil.arm-64.asm │ │ └── flagbrot.arm-64.asm │ ├── Aissen │ │ └── anisse.arm-32.asm │ ├── # │ │ ├── old │ │ │ └── unnamedreplicator.x86-32.asm │ │ ├── hayirlisiolsun.x86-32.asm │ │ └── hayirlisiolsun.x86-32_comments.asm │ ├── Austin Emmitt │ │ └── alkalinear.arm-64.asm │ ├── lars │ │ └── zutle.x86-32.asm │ ├── goyo │ │ ├── flacucho.arm-32.asm │ │ └── gordasco.x86-32.asm │ ├── CaptnBanana │ │ └── FATbanana.x86-32.asm │ └── 현수 차 │ │ └── soo.x86-32.asm │ ├── round1 │ ├── erfur PhD 1080p │ │ └── kaploombaa.x86-32.asm │ ├── Anirudh │ │ └── icyphox.x86-32.asm │ ├── 현수 차 │ │ └── soo.x86-32.asm │ ├── CaptnBanana │ │ └── banana_of_doom.x86-32.asm │ ├── goyo │ │ ├── flacucho-hex.arm-32.asm │ │ └── gordasco.x86-32.asm │ ├── Aissen │ │ └── anisse.arm-32.asm │ ├── # │ │ ├── hayirlisiolsun.x86-32.asm │ │ └── old │ │ │ └── unnamedreplicator.x86-32.asm │ ├── Austin Emmitt │ │ └── alkalinear.arm-64.asm │ └── lars │ │ └── zutle.x86-32.asm │ └── round2 │ ├── erfur PhD 1080p │ └── kaploombaa.x86-32.asm │ ├── 현수 차 │ └── soo.x86-32.asm │ ├── ADAM WEST │ └── oldMacaco.x86-32.asm │ ├── karliss │ └── karliss.x86-64.asm │ ├── CaptnBanana │ └── banana_of_doom.x86-32.asm │ ├── robin │ └── hexrays.x86-32.asm │ ├── Aissen │ └── anisse.arm-32.asm │ ├── Anirudh │ └── icyphox.x86-32.asm │ ├── # │ ├── old │ │ └── unnamedreplicator.x86-32.asm │ └── hayirlisiolsun.x86-32.asm │ ├── Austin Emmitt │ └── alkalinear.arm-64.asm │ ├── goyo │ ├── flacucho.arm-32.asm │ └── gordasco.x86-32.asm │ └── lars │ └── zutle.x86-32.asm ├── .dockerignore ├── compose.yaml ├── warriors ├── max.x86-32.asm └── FATbanana.x86-32.asm ├── Makefile ├── RELEASE_README.md ├── README.md └── Dockerfile /csharp/examples: -------------------------------------------------------------------------------- 1 | ../examples -------------------------------------------------------------------------------- /vlang/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | v run main.v 3 | -------------------------------------------------------------------------------- /python/show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/python/show.jpg -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/MonoAndroid10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/MonoTouch10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/xamarinios10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/xamarinmac20/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/xamarintvos10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/ref/MonoAndroid10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/ref/MonoTouch10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/ref/xamarinios10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/ref/xamarinmac20/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/ref/xamarintvos10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/xamarinwatchos10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/ref/xamarinwatchos10/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/pancake.arm-32.asm: -------------------------------------------------------------------------------- 1 | mov r0, pc 2 | loop: 3 | str r0, [r0, 0] 4 | sub r0, r0, 8 5 | b loop 6 | -------------------------------------------------------------------------------- /csharp/resources/r2wars_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/resources/r2wars_logo.png -------------------------------------------------------------------------------- /examples/pancake.x86-32.asm: -------------------------------------------------------------------------------- 1 | call rest 2 | rest: 3 | pop esp 4 | rep: 5 | add esp, 64 6 | pusha 7 | jmp rep 8 | -------------------------------------------------------------------------------- /python/t/pancake.x86-32.asm: -------------------------------------------------------------------------------- 1 | call rest 2 | rest: 3 | pop esp 4 | rep: 5 | add esp, 64 6 | pusha 7 | jmp rep 8 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # Ignore everything... 2 | * 3 | # ...apart from the csharp subdirectory which is the only one that's needed 4 | !csharp/ 5 | -------------------------------------------------------------------------------- /csharp/resources/r2wars_logo_transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/resources/r2wars_logo_transparent.png -------------------------------------------------------------------------------- /csharp/packages/Nancy.1.4.4/Nancy.1.4.4.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/Nancy.1.4.4/Nancy.1.4.4.nupkg -------------------------------------------------------------------------------- /csharp/packages/Nancy.1.4.4/lib/net40/Nancy.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/Nancy.1.4.4/lib/net40/Nancy.dll -------------------------------------------------------------------------------- /python/t/test.x86-32: -------------------------------------------------------------------------------- 1 | call label 2 | label: 3 | pop eax 4 | loop: 5 | sub eax, 10 6 | cmp [eax], 0 7 | je loop 8 | mov [eax], 0 9 | jmp loop 10 | -------------------------------------------------------------------------------- /examples/hmht.8051.asm: -------------------------------------------------------------------------------- 1 | mov dptr, #kill 2 | loop: 3 | inc dptr 4 | inc dptr 5 | inc dptr 6 | inc a 7 | movx @dptr, a 8 | sjmp loop 9 | kill: 10 | -------------------------------------------------------------------------------- /python/t/test2.x86-32: -------------------------------------------------------------------------------- 1 | call label 2 | label: 3 | pop eax 4 | loop: 5 | sub eax, 10 6 | cmp [eax], 0 7 | je loop 8 | mov [eax], 0 9 | jmp loop 10 | -------------------------------------------------------------------------------- /examples/r2con2021/final/kamehameha.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov eax, 0x100 2 | mov esp, eax 3 | mov ebp, 0xe4ff6060 4 | mov esi, 0x6060e046 5 | mov edi, 0x0f60fc83 6 | pusha 7 | jmp esp -------------------------------------------------------------------------------- /python/t/pancake.gb.asm: -------------------------------------------------------------------------------- 1 | .arch gb 2 | call test 3 | test: 4 | pop bc 5 | ld hl, 8 6 | ld sp, bc 7 | rep: 8 | push bc 9 | add hl, sp 10 | jr rep 11 | -------------------------------------------------------------------------------- /python/t/pancake.mips-32.asm: -------------------------------------------------------------------------------- 1 | .arch mips 2 | .bits 32 3 | bal here 4 | here: 5 | move t0, ra 6 | rep: 7 | subu t0, t0, 8 8 | sw t0, 0(t0) 9 | j rep 10 | -------------------------------------------------------------------------------- /examples/pancake.mips-64.asm: -------------------------------------------------------------------------------- 1 | bal 0 + getpc 2 | getpc: 3 | move v0, ra 4 | lui v1, 1 5 | loop: 6 | sw v0, 0(v1) 7 | addiu v1, v1, v0 8 | b loop 9 | nop 10 | -------------------------------------------------------------------------------- /csharp/packages/WebSocketSharp.1.0.3-rc11/lib/websocket-sharp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/WebSocketSharp.1.0.3-rc11/lib/websocket-sharp.dll -------------------------------------------------------------------------------- /examples/jordi.x86-32.asm: -------------------------------------------------------------------------------- 1 | call label 2 | label: 3 | pop eax 4 | loop: 5 | sub eax, 10 6 | cmp dword ptr[eax], 0 7 | je loop 8 | mov dword ptr[eax], 0 9 | jmp loop 10 | -------------------------------------------------------------------------------- /csharp/packages/Nancy.Hosting.Self.1.4.1/Nancy.Hosting.Self.1.4.1.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/Nancy.Hosting.Self.1.4.1/Nancy.Hosting.Self.1.4.1.nupkg -------------------------------------------------------------------------------- /examples/r2con2020/round3/kurt/niku.x86-64.asm: -------------------------------------------------------------------------------- 1 | dec rax 2 | mov rcx, 126 3 | mov rsp, 0x400 4 | mov rbx, 0xf3eb505050505050 5 | mov rdx, 0x5050505050ab48f3 6 | push rbx 7 | push rdx 8 | jmp rsp 9 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/kurt/niku.x86-64.asm: -------------------------------------------------------------------------------- 1 | dec rax 2 | mov rcx, 126 3 | mov rsp, 0x400 4 | mov rbx, 0xf3eb505050505050 5 | mov rdx, 0x5050505050ab48f3 6 | push rbx 7 | push rdx 8 | jmp rsp 9 | -------------------------------------------------------------------------------- /csharp/packages/Nancy.Hosting.Self.1.4.1/lib/net40/Nancy.Hosting.Self.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/Nancy.Hosting.Self.1.4.1/lib/net40/Nancy.Hosting.Self.dll -------------------------------------------------------------------------------- /csharp/packages/WebSocketSharp.1.0.3-rc11/WebSocketSharp.1.0.3-rc11.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/WebSocketSharp.1.0.3-rc11/WebSocketSharp.1.0.3-rc11.nupkg -------------------------------------------------------------------------------- /csharp/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/erfur PhD 1080p/kaploombaa.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; kaploombaa 2 | .arch x86 3 | .bits 32 4 | mov eax, 0x00004000 5 | mov ebx, 0x0003fcff 6 | mov edi, 0x000070bc 7 | mov esi, 0x21c70100 8 | mov ebp, 0xe4ff60df 9 | mov esp, 0x40 10 | pushal 11 | jmp esp 12 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/erfur PhD 1080p/kaploombaa.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; kaploombaa 2 | .arch x86 3 | .bits 32 4 | mov eax, 0x00011000 5 | mov ebx, 0x0003fcff 6 | mov edi, 0x0003fcbc 7 | mov esi, 0x21c70100 8 | mov ebp, 0xe4ff60df 9 | mov esp, 0x220 10 | pushal 11 | jmp esp 12 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/erfur PhD 1080p/kaploombaa.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; kaploombaa 2 | .arch x86 3 | .bits 32 4 | mov esp, 0x70; 5 | mov eax, 0x00008000; 6 | mov ebx, 0x0003ffff; 7 | mov edi, 0x000070bc; 8 | mov esi, 0x21c70100; 9 | mov ebp, 0xe4ff60df; 10 | pushal; 11 | jmp esp; 12 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/erfur PhD 1080p/kaploombaa.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; kaploombaa 2 | .arch x86 3 | .bits 32 4 | mov esp, 0x70; 5 | mov eax, 0x00008000; 6 | mov ebx, 0x0003ffff; 7 | mov edi, 0x000070bc; 8 | mov esi, 0x21c70100; 9 | mov ebp, 0xe4ff60df; 10 | pushal; 11 | jmp esp; 12 | -------------------------------------------------------------------------------- /examples/r2con2021/final/ricardoapl.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov edi, 0x0f60fc83 2 | mov esi, 0x6060e04c 3 | mov ebp, 0xffe4ff60 4 | 5 | mov esp, 0x00000200 6 | 7 | mov ebx, 0xffffffff 8 | mov edx, 0xffffffff 9 | mov ecx, 0xffffffff 10 | mov eax, 0x00000400 11 | 12 | pushal 13 | jmp esp 14 | -------------------------------------------------------------------------------- /examples/r2con2021/round1/ricardoapl.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov edi, 0x0f60fc83 2 | mov esi, 0x6060e04c 3 | mov ebp, 0xffe4ff60 4 | 5 | mov esp, 0x00000200 6 | 7 | mov ebx, 0xffffffff 8 | mov edx, 0xffffffff 9 | mov ecx, 0xffffffff 10 | mov eax, 0x00000400 11 | 12 | pushal 13 | jmp esp 14 | -------------------------------------------------------------------------------- /examples/r2con2021/round2/ricardoapl.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov edi, 0x0f60fc83 2 | mov esi, 0x6060e04c 3 | mov ebp, 0xffe4ff60 4 | 5 | mov esp, 0x00000200 6 | 7 | mov ebx, 0xffffffff 8 | mov edx, 0xffffffff 9 | mov ecx, 0xffffffff 10 | mov eax, 0x00000400 11 | 12 | pushal 13 | jmp esp 14 | -------------------------------------------------------------------------------- /csharp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | r2wars: 3 | image: r2wars:latest 4 | build: . 5 | volumes: 6 | - ./warriors:/r2wars/warriors:ro 7 | ports: 8 | - 127.0.0.1:9664:9664 9 | - 127.0.0.1:9966:9966 10 | init: true 11 | tty: true 12 | container_name: r2wars 13 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/Anirudh/icyphox.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; when i say jump -- you say how high 2 | 3 | mov eax, 0xfeebfeeb; feebfeeb 4 | mov ebx, eax 5 | mov ecx, eax 6 | mov edx, eax 7 | mov ebp, eax 8 | mov edi, eax 9 | mov esp, 0x3fc 10 | mov esi, 0x3fd 11 | mov [esi], 0xe6ff60 12 | jmp esi 13 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/현수 차/soo.x86-32.asm: -------------------------------------------------------------------------------- 1 | call get_eip 2 | get_eip: 3 | pop esp 4 | sub ecx, 0x20 5 | dec eax 6 | 7 | qq: 8 | 9 | 10 | pushad 11 | pushad 12 | pushad 13 | 14 | add esp, ecx 15 | dec ecx 16 | cmp esp, 0x80 17 | ja qq 18 | mov esp, 0x3a0 19 | jmp qq 20 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/ADAM WEST/oldMacaco.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov eax, 0xc3c3c3c3 2 | mov ebx, 1024 3 | mov edx, 0xa0 4 | mov ebp, 0xe4ff6060 5 | mov esi, 0x606060e3 6 | mov edi, 0x420fd439 7 | call pwn 8 | pwn: 9 | pop esp 10 | sub esp,4 11 | pushad 12 | mov esp, 0x340 13 | pushad 14 | jmp esp 15 | 16 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/ADAM WEST/oldMacaco.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov eax, 0xc3c3c3c3 2 | mov ebx, 1024 3 | mov edx, 0xa0 4 | mov ebp, 0xe4ff6060 5 | mov esi, 0x606060e3 6 | mov edi, 0x420fd439 7 | call pwn 8 | pwn: 9 | pop esp 10 | sub esp,4 11 | pushad 12 | mov esp, 0x340 13 | pushad 14 | jmp esp 15 | 16 | -------------------------------------------------------------------------------- /warriors/max.x86-32.asm: -------------------------------------------------------------------------------- 1 | call get_eip 2 | and esp, 0xffc0 3 | mov ebx, 0x39ffffff 4 | mov edx, 0xe6440ffc 5 | mov ecx, 0x6c8d6060 6 | mov eax, 0xe5ff3324 7 | pushad 8 | pushad 9 | mov esi, 1024 10 | lea ebp, [esp + 19] 11 | mov edi, 0 12 | jmp ebp 13 | 14 | get_eip: 15 | mov esp, [esp] 16 | ret 17 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/System.Runtime.InteropServices.RuntimeInformation.4.3.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/System.Runtime.InteropServices.RuntimeInformation.4.3.0.nupkg -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/win8/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/win8/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /examples/r2con2021/round2/karma.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov ebp, 0x400 2 | mov esp, ebp 3 | mov esi, 0x0f0b0f0b 4 | mov edi, 0x0f0b0f0b 5 | mov ecx, 0x0f0b0f0b 6 | mov edx, 0x0f0b0f0b 7 | mov ebx, 0x0f0b0f0b 8 | mov eax, 0x0f0b0f0b 9 | start: 10 | pushad 11 | sub esp, 0x20 12 | and esp, 0x3ff 13 | jmp start -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/net45/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/net45/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/wpa81/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/wpa81/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/ref/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/ref/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /examples/r2con2020/round2/karliss/karliss.x86-64.asm: -------------------------------------------------------------------------------- 1 | lea rsp, [0x25] 2 | mov rbx, qword[rsp] 3 | mov rcx, qword[rsp+8] 4 | mov r10, 0x25f 5 | mov r11, 0x3f0 6 | mov r12, 0x10 7 | 8 | add rsp, r10 9 | and rsp, r11 10 | add rsp, r12 11 | push rcx 12 | push rbx 13 | jmp rsp 14 | nop 15 | nop 16 | nop 17 | nop 18 | nop 19 | nop 20 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/karliss/karliss.x86-64.asm: -------------------------------------------------------------------------------- 1 | lea rsp, [0x25] 2 | mov rbx, qword[rsp] 3 | mov rcx, qword[rsp+8] 4 | mov r10, 0x25f 5 | mov r11, 0x3f0 6 | mov r12, 0x10 7 | 8 | add rsp, r10 9 | and rsp, r11 10 | add rsp, r12 11 | push rcx 12 | push rbx 13 | jmp rsp 14 | nop 15 | nop 16 | nop 17 | nop 18 | nop 19 | nop 20 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/karliss/karliss.x86-64.asm: -------------------------------------------------------------------------------- 1 | lea rsp, [0x25] 2 | mov rbx, qword[rsp] 3 | mov rcx, qword[rsp+8] 4 | mov r10, 0x25f 5 | mov r11, 0x3f0 6 | mov r12, 0x10 7 | 8 | add rsp, r10 9 | and rsp, r11 10 | add rsp, r12 11 | push rcx 12 | push rbx 13 | jmp rsp 14 | nop 15 | nop 16 | nop 17 | nop 18 | nop 19 | nop 20 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/현수 차/soo.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov esp, 0x3c8 2 | 3 | mov ebx, 0x01606060 4 | mov edx, 0x664949cc 5 | mov ecx, 0x0080fc81 6 | mov eax, 0xbc66f277 7 | pushad 8 | mov dword ptr[esp+0x20],0xeceb0390 9 | 10 | call get_eip 11 | get_eip: 12 | pop esp 13 | mov ecx, 0xFFFFFFe9 14 | 15 | mov eax, 0x3b8 16 | jmp eax -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/win/lib/net45/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/win/lib/net45/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/aot/lib/netcore50/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/aot/lib/netcore50/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/win/lib/netcore50/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/win/lib/netcore50/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/win/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/win/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /examples/r2con2020/round4/ADAM WEST/ThreeHeadedMonkey.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov eax, 0xc3c3c3c3 2 | mov ebx, 1024 3 | mov edx, 0x84 4 | mov ebp, eax 5 | mov esi, 0xe4ff5160 6 | mov edi, 0x606060e3 7 | mov ecx, 0x420fd439 8 | mov esp, 0xa8 9 | call pwn 10 | pwn: 11 | pop esp 12 | sub esp,4 13 | pusha 14 | mov esp, 0xa8 15 | pusha 16 | push ecx 17 | jmp esp 18 | 19 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/Anirudh/icyphox.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov eax, 0xffffffff 2 | mov ecx, eax 3 | mov edx, eax 4 | mov ebx, eax 5 | mov ebp, eax 6 | mov esi, eax 7 | 8 | mov edi, 0xd 9 | mov esp, 0x400 10 | mov [edi], 0x20fc8360 11 | mov [edi+4], 0xff600374 12 | mov [edi+8], 0x0400bce7 13 | mov [edi+12], 0xe7ff0000 14 | ;mov [edi], 0xe7ff6060 15 | jmp edi 16 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/unix/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/radareorg/r2wars/master/csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/runtimes/unix/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll -------------------------------------------------------------------------------- /examples/r2con2021/final/theta.arm-32.asm: -------------------------------------------------------------------------------- 1 | .arch arm 2 | .bits 32 3 | .hex 0cd08fe2 4 | .hex ff07bde8 5 | .hex 40d200e3 6 | .hex ffff2de9 7 | .hex 1dff2fe1 8 | .hex 00005de3 9 | .hex 01dba0d3 10 | .hex ffff2de9 11 | .hex ffff2de9 12 | .hex ffff2de9 13 | .hex ffff2de9 14 | .hex ffff2de9 15 | .hex ffff2de9 16 | .hex ffff2de9 17 | .hex ffff2de9 18 | .hex 1dff2fe1 19 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/현수 차/soo.x86-32.asm: -------------------------------------------------------------------------------- 1 | call get_eip 2 | 3 | get_eip: 4 | 5 | pop esp 6 | 7 | 8 | qq: 9 | 10 | mov [esp+0x30], esp 11 | 12 | pushad 13 | 14 | pushad 15 | 16 | pushad 17 | 18 | popad 19 | 20 | popad 21 | 22 | popad 23 | add esp, ecx 24 | 25 | dec ecx 26 | cmp esp, 0x80 27 | ja qq 28 | mov esp, 0x3a0 29 | jmp qq 30 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/CaptnBanana/banana_of_doom.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov ebx, 0x69696969 2 | mov ecx, ebx 3 | mov edx, 0x400 4 | 5 | mov edi, 0xd439c401 6 | mov esi, 0x60e04f0f 7 | mov ebp, 0xe4ff6060 8 | 9 | mov esp, 0x215 10 | pushad 11 | mov esp, 0x25 12 | pushad 13 | mov esp, 0x3f9 14 | pushad 15 | 16 | mov esp, 0x310 17 | pushad 18 | pushad 19 | mov eax, 0xB9 20 | jmp esp 21 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/CaptnBanana/banana_of_doom.x86-32.asm: -------------------------------------------------------------------------------- 1 | mov ebx, 0x69696969 2 | mov ecx, ebx 3 | mov edx, 0x400 4 | 5 | mov edi, 0xd439c401 6 | mov esi, 0x60e04f0f 7 | mov ebp, 0xe4ff6060 8 | 9 | mov esp, 0x215 10 | pushad 11 | mov esp, 0x25 12 | pushad 13 | mov esp, 0x3f9 14 | pushad 15 | 16 | mov esp, 0x310 17 | pushad 18 | pushad 19 | mov eax, 0xB9 20 | jmp esp 21 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/goyo/flacucho-hex.arm-32.asm: -------------------------------------------------------------------------------- 1 | .bits 32 2 | .arch arm 3 | .hex 3f6e 4 | .hex a0e3 5 | .hex 0620 6 | .hex 00e3 7 | .hex 5121 8 | .hex 4ee3 9 | .hex 0030 10 | .hex 01e3 11 | .hex a031 12 | .hex 48e3 13 | .hex 3c40 14 | .hex 00e3 15 | .hex a148 16 | .hex 4ee3 17 | .hex 0f50 18 | .hex 0fe3 19 | .hex 4152 20 | .hex 4ee3 21 | .hex 0010 22 | .hex 8fe2 23 | .hex 3c00 24 | .hex a1e8 25 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/robin/hexrays.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; This bot sucks but I wamted to make something 2 | mov esp, 0x3de 3 | mov edx, 0xdead 4 | mov ebx, 0xdead 5 | mov ecx, 0xdead 6 | jmp loop 7 | hijack: 8 | jmp eax 9 | loop: 10 | inc al 11 | cmp eax, 0x3de 12 | jle continue 13 | xor eax, eax 14 | continue: 15 | cmp [eax], 0x00 16 | jne hijack 17 | pushal 18 | jmp loop 19 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/Anirudh/icyphox.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; when i say jump -- you say how high 2 | 3 | mov eax, 0xffffffff 4 | mov ecx, eax 5 | mov edx, eax 6 | mov ebx, eax 7 | mov ebp, eax 8 | mov esi, eax 9 | 10 | mov edi, 0x000 11 | mov esp, 0x400 12 | mov [edi], 0x20fc8360 13 | mov [edi+4], 0xff600374 14 | mov [edi+8], 0x0400bce7 15 | mov [edi+12], 0xe7ff0000 16 | ;mov [edi], 0xe7ff6060 17 | jmp edi 18 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/robin/hexrays.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; This bot sucks but I wamted to make something 2 | mov esp, 0x3de 3 | mov edx, 0xdead 4 | mov ebx, 0xdead 5 | mov ecx, 0xdead 6 | jmp loop 7 | hijack: 8 | jmp eax 9 | loop: 10 | inc al 11 | cmp eax, 0x3de 12 | jle continue 13 | xor eax, eax 14 | continue: 15 | cmp [eax], 0x00 16 | jne hijack 17 | pushal 18 | jmp loop 19 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/robin/hexrays.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; This bot sucks but I wamted to make something 2 | mov esp, 0x3de 3 | mov edx, 0xdead 4 | mov ebx, 0xdead 5 | mov ecx, 0xdead 6 | jmp loop 7 | hijack: 8 | jmp eax 9 | loop: 10 | inc al 11 | cmp eax, 0x3de 12 | jle continue 13 | xor eax, eax 14 | continue: 15 | cmp [eax], 0x00 16 | jne hijack 17 | pushal 18 | jmp loop 19 | -------------------------------------------------------------------------------- /csharp/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /csharp/MyEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | public delegate void MyHandler1(object sender, MyEvent e); 3 | public class MyEvent : EventArgs 4 | { 5 | public string message; 6 | public int ganador; 7 | public int perdedor; 8 | public string winnername; 9 | public string losername; 10 | public string loserreason; 11 | public string loserins; 12 | public int round; 13 | public int ciclos; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/Aissen/anisse.arm-32.asm: -------------------------------------------------------------------------------- 1 | # Anisse Astier 2 | .arch arm 3 | .bits 32 4 | .hex 0c008fe2 5 | .hex fe7fb0e8 6 | .hex 020ca0e3 7 | .hex fe7f80e8 8 | .hex 81ffa0e3 9 | .hex 3f0e00e2 10 | .hex fe7fa0e8 11 | .hex fe7fa0e8 12 | .hex fe7fa0e8 13 | .hex fe7fa0e8 14 | .hex fe7fa0e8 15 | .hex fe7fa0e8 16 | .hex fe7fa0e8 17 | .hex fe7fa0e8 18 | .hex fe7fa0e8 19 | .hex 0600a0e8 20 | .hex f3ffffea 21 | .hex cccccccc 22 | .hex cccccccc 23 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/Aissen/anisse.arm-32.asm: -------------------------------------------------------------------------------- 1 | # Anisse Astier 2 | .arch arm 3 | .bits 32 4 | .hex 0c008fe2 5 | .hex fe7fb0e8 6 | .hex 020ca0e3 7 | .hex fe7f80e8 8 | .hex 81ffa0e3 9 | .hex 3f0e00e2 10 | .hex fe7fa0e8 11 | .hex fe7fa0e8 12 | .hex fe7fa0e8 13 | .hex fe7fa0e8 14 | .hex fe7fa0e8 15 | .hex fe7fa0e8 16 | .hex fe7fa0e8 17 | .hex fe7fa0e8 18 | .hex fe7fa0e8 19 | .hex 0600a0e8 20 | .hex f3ffffea 21 | .hex cccccccc 22 | .hex cccccccc 23 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/#/hayirlisiolsun.x86-32.asm: -------------------------------------------------------------------------------- 1 | pack: 2 | ; mov edi, 0xcccccccc 3 | ; mov esi, 0xcccccccc 4 | ; mov ebp, 0xcccccccc 5 | mov ebx, 0x00000400 6 | mov edx, 0x6060dc89 7 | mov ecx, 0x60606060 8 | mov eax, 0xf9eb6060 9 | unpack: 10 | mov esp, 0x20 11 | pushad 12 | add esp, 0x14 ; if shorter 13 | jmp esp 14 | loop: 15 | inc eax 16 | jmp loop 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/Anirudh/icyphox.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; when i say jump -- you say how high 2 | 3 | mov eax, 0xffffffff 4 | mov ecx, eax 5 | mov edx, eax 6 | mov ebx, eax 7 | mov ebp, eax 8 | mov esi, eax 9 | 10 | check: 11 | mov edi, 0x000 12 | cmp [edi], 0 13 | jne planb 14 | mov esp, 0x400 15 | inc edi 16 | mov [edi], 0xe7ff6060 17 | jmp edi 18 | 19 | planb: 20 | mov edi, 0x3fb 21 | mov [edi], 0xe7ff6060 22 | mov esp, 0x3fa 23 | jmp edi 24 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/cyanpencil/cyanpencil.arm-64.asm: -------------------------------------------------------------------------------- 1 | # initial setup 2 | adr x0, start 3 | add x0, x0, 0x23 4 | movz x3, 0x1d8 5 | movz x4, 0x200 6 | ldp x1, x2, [x0], 16 7 | ldp x8, x9, [x0], 16 8 | stp x1, x2, [x4] 9 | stp x8, x9, [x4], 16 10 | br x4 11 | 12 | 13 | 14 | loop: 15 | stp x1, x2, [x3], 0x10 16 | stp x8, x9, [x3], -0x38 17 | tbz x3, 30, -12 18 | 19 | # if we got below 0x0: 20 | add x3, x3, 0x3f8 21 | stp x1, x2, [x3, 0x10]! 22 | sub x3, x3, 0x28 23 | b 0x3cc 24 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/Aissen/anisse.arm-32.asm: -------------------------------------------------------------------------------- 1 | # Anisse Astier 2 | .arch arm 3 | .bits 32 4 | .hex 18d08fe2 5 | .hex ff5fbde8 6 | .hex 34d0b0e3 7 | .hex ff07ade8 8 | .hex f00fade8 9 | .hex 0f005ee1 10 | .hex 80d0a043 11 | .hex 44f0a043 12 | .hex 3fde0d42 13 | .hex ff1fad48 14 | .hex ff07ad48 15 | .hex f00fad48 16 | .hex ffffad48 17 | .hex ffffad48 18 | .hex ffffad48 19 | .hex ffffad48 20 | .hex ffffad48 21 | .hex ffffad48 22 | .hex ffffad48 23 | .hex ecffff4a 24 | .hex 0100005f 25 | .hex ccc3ccc3 26 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/Aissen/anisse.arm-32.asm: -------------------------------------------------------------------------------- 1 | # Anisse Astier 2 | .arch arm 3 | .bits 32 4 | .hex 18d08fe2 5 | .hex ff5fbde8 6 | .hex 34d0b0e3 7 | .hex ff07ade8 8 | .hex f00fade8 9 | .hex 0f005ee1 10 | .hex 80d0a043 11 | .hex 44f0a043 12 | .hex 3fde0d42 13 | .hex ff1fad48 14 | .hex ff07ad48 15 | .hex f00fad48 16 | .hex ffffad48 17 | .hex ffffad48 18 | .hex ffffad48 19 | .hex ffffad48 20 | .hex ffffad48 21 | .hex ffffad48 22 | .hex ffffad48 23 | .hex ecffff4a 24 | .hex 0100005f 25 | .hex ccc3ccc3 26 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DOCKER ?= sudo docker 2 | 3 | .PHONY: default build start stop clean 4 | 5 | default: start ## By default, just start the container 6 | 7 | build: ## Build the Docker image 8 | @$(DOCKER) compose build 9 | 10 | start: ## Start the container via docker compose (docker compose builds automatically if necessary) 11 | @$(DOCKER) compose up -d 12 | 13 | stop: ## Tear down the container via docker compose 14 | @$(DOCKER) compose down 15 | 16 | clean: ## Remove the docker image 17 | @$(DOCKER) rmi r2wars:latest 18 | 19 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/#/old/unnamedreplicator.x86-32.asm: -------------------------------------------------------------------------------- 1 | call init 2 | init: 3 | pop esp 4 | add esp, 0x26 5 | mov dword [eax], esp ; esp saved @0x0 6 | sub esp, 0x20 7 | save: 8 | popad 9 | jmp restore 10 | .hex 0xcccccccc 11 | .hex 0xcccccccc 12 | .hex 0xcccccccc 13 | .hex 0xcccccccc 14 | restore: 15 | mov esp, dword [0x0] 16 | add esp, 0x20 17 | xor esi, esi 18 | mov dword [esi], esp 19 | pushad 20 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/#/old/unnamedreplicator.x86-32.asm: -------------------------------------------------------------------------------- 1 | call init 2 | init: 3 | pop esp 4 | add esp, 0x26 5 | mov dword [eax], esp ; esp saved @0x0 6 | sub esp, 0x20 7 | save: 8 | popad 9 | jmp restore 10 | .hex 0xcccccccc 11 | .hex 0xcccccccc 12 | .hex 0xcccccccc 13 | .hex 0xcccccccc 14 | restore: 15 | mov esp, dword [0x0] 16 | add esp, 0x20 17 | xor esi, esi 18 | mov dword [esi], esp 19 | pushad 20 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/#/old/unnamedreplicator.x86-32.asm: -------------------------------------------------------------------------------- 1 | call init 2 | init: 3 | pop esp 4 | add esp, 0x26 5 | mov dword [eax], esp ; esp saved @0x0 6 | sub esp, 0x20 7 | save: 8 | popad 9 | jmp restore 10 | .hex 0xcccccccc 11 | .hex 0xcccccccc 12 | .hex 0xcccccccc 13 | .hex 0xcccccccc 14 | restore: 15 | mov esp, dword [0x0] 16 | add esp, 0x20 17 | xor esi, esi 18 | mov dword [esi], esp 19 | pushad 20 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/#/old/unnamedreplicator.x86-32.asm: -------------------------------------------------------------------------------- 1 | call init 2 | init: 3 | pop esp 4 | add esp, 0x26 5 | mov dword [eax], esp ; esp saved @0x0 6 | sub esp, 0x20 7 | save: 8 | popad 9 | jmp restore 10 | .hex 0xcccccccc 11 | .hex 0xcccccccc 12 | .hex 0xcccccccc 13 | .hex 0xcccccccc 14 | restore: 15 | mov esp, dword [0x0] 16 | add esp, 0x20 17 | xor esi, esi 18 | mov dword [esi], esp 19 | pushad 20 | -------------------------------------------------------------------------------- /csharp/Torneo/PairingsGeneratorState.cs: -------------------------------------------------------------------------------- 1 | /// 2 | /// Describes the current state of a pairings generator. 3 | /// 4 | public enum PairingsGeneratorState 5 | { 6 | /// 7 | /// Indicates that the pairings generator is not initialized. 8 | /// 9 | NotInitialized, 10 | 11 | /// 12 | /// Indicates that the pairings generator has been initialized to a valid state. 13 | /// 14 | Initialized 15 | } 16 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/Austin Emmitt/alkalinear.arm-64.asm: -------------------------------------------------------------------------------- 1 | sub x20, x20, 16; 2 | movk x21, 0x1ff; 3 | 4 | bl start; 5 | start: 6 | movk x22, 0x8a; 7 | strb w22, [x30, 23]; // patch ORR -> AND 8 | ldp x0, x1, [x30, 16]; // copy 9 | ldp x2, x3, [x30, 32]; // copy 10 | 11 | add x20, x20, 32; 12 | orr x20, x20, x21; // becomes AND 13 | stp x0, x1, [x20, 120]; // stomp 14 | stp x0, x1, [x20, 480]; // stomp 15 | stp x2, x3, [x20, 496]; // stomp 16 | stp x0, x1, [x20, 0]; // paste 17 | stp x2, x3, [x20, 16]; // paste 18 | br x20; -------------------------------------------------------------------------------- /examples/r2con2020/round2/Austin Emmitt/alkalinear.arm-64.asm: -------------------------------------------------------------------------------- 1 | sub x20, x20, 16; 2 | movk x21, 0x1ff; 3 | 4 | bl start; 5 | start: 6 | movk x22, 0x8a; 7 | strb w22, [x30, 23]; // patch ORR -> AND 8 | ldp x0, x1, [x30, 16]; // copy 9 | ldp x2, x3, [x30, 32]; // copy 10 | 11 | add x20, x20, 32; 12 | orr x20, x20, x21; // becomes AND 13 | stp x0, x1, [x20, 120]; // stomp 14 | stp x0, x1, [x20, 480]; // stomp 15 | stp x2, x3, [x20, 496]; // stomp 16 | stp x0, x1, [x20, 0]; // paste 17 | stp x2, x3, [x20, 16]; // paste 18 | br x20; -------------------------------------------------------------------------------- /examples/r2con2020/round3/Austin Emmitt/alkalinear.arm-64.asm: -------------------------------------------------------------------------------- 1 | sub x20, x20, 16; 2 | movk x21, 0x1ff; 3 | 4 | bl start; 5 | start: 6 | movk x22, 0x8a; 7 | strb w22, [x30, 23]; // patch ORR -> AND 8 | ldp x0, x1, [x30, 16]; // copy 9 | ldp x2, x3, [x30, 32]; // copy 10 | 11 | add x20, x20, 32; 12 | orr x20, x20, x21; // becomes AND 13 | stp x0, x1, [x20, 120]; // stomp 14 | stp x0, x1, [x20, 480]; // stomp 15 | stp x2, x3, [x20, 496]; // stomp 16 | stp x0, x1, [x20, 0]; // paste 17 | stp x2, x3, [x20, 16]; // paste 18 | br x20; -------------------------------------------------------------------------------- /examples/r2con2020/round4/Austin Emmitt/alkalinear.arm-64.asm: -------------------------------------------------------------------------------- 1 | sub x20, x20, 16; 2 | movk x21, 0x1ff; 3 | 4 | bl start; 5 | start: 6 | movk x22, 0x8a; 7 | strb w22, [x30, 23]; // patch ORR -> AND 8 | ldp x0, x1, [x30, 16]; // copy 9 | ldp x2, x3, [x30, 32]; // copy 10 | 11 | add x20, x20, 32; 12 | orr x20, x20, x21; // becomes AND 13 | stp x0, x1, [x20, 120]; // stomp 14 | stp x0, x1, [x20, 480]; // stomp 15 | stp x2, x3, [x20, 496]; // stomp 16 | stp x0, x1, [x20, 0]; // paste 17 | stp x2, x3, [x20, 16]; // paste 18 | br x20; -------------------------------------------------------------------------------- /examples/r2con2020/round4/cyanpencil/flagbrot.arm-64.asm: -------------------------------------------------------------------------------- 1 | adr x0, start 2 | add x0, x0, 0x23 3 | movz x3, 0x1d8 4 | movz x4, 0x200 5 | .hex 0108C1A8 // ldp x1, x2, [x0], 16 6 | .hex 0824C1A8 // ldp x8, x9, [x0], 16 7 | .hex 810800A9 // stp x1, x2, [x4] 8 | .hex 882401A9 // stp x8, x9, [x4], 16 9 | br x4 10 | 11 | 12 | 13 | loop: 14 | .hex 610881A8 //stp x1, x2, [x3, 0x10]! 15 | .hex 68A4BCA8 //stp x8, x9, [x3, 0x10] 16 | .hex 83FEF736 //tbz x3, 30, -12 17 | 18 | 19 | 20 | # ---- if loop: 21 | add x3, x3, 0x3f8 22 | .hex 610800A9 //stp x1, x2, [x3, 0x10]! 23 | sub x3, x3, 0x28 24 | b 0x3cc 25 | -------------------------------------------------------------------------------- /csharp/lsbots.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ( 3 | for a in warriors/* ; do 4 | if [ "`echo $a | grep txt$`" ]; then 5 | continue; 6 | fi 7 | printf "$a " 8 | if [ "`echo $a | grep x86-32`" ]; then 9 | rasm2 -a x86 -b 32 -f $a |wc -c 10 | elif [ "`echo $a | grep arm-64`" ]; then 11 | rasm2 -a arm -b 64 -f $a |wc -c 12 | elif [ "`echo $a | grep arm-16`" ]; then 13 | rasm2 -a arm -b 16 -f $a |wc -c 14 | elif [ "`echo $a | grep mips-32`" ]; then 15 | rasm2 -a mips -b 32 -f $a |wc -c 16 | elif [ "`echo $a | grep 8051`" ]; then 17 | rasm2 -a 8051 -f $a |wc -c 18 | fi 19 | done 20 | ) |awk '{print $2"\t"$1}' 21 | -------------------------------------------------------------------------------- /examples/r2con2021/final/zeta.arm-32.asm: -------------------------------------------------------------------------------- 1 | _start: 2 | ldr r0, [pc, #48] 3 | ldr r1, [pc, #48] 4 | ldr r2, [pc, #48] 5 | ldr r3, [pc, #44] 6 | ldr r4, [pc, #40] 7 | ldr r5, [pc, #36] 8 | ldr r6, [pc, #36] 9 | 10 | movt r7, #0xffff 11 | movt r8, #0xffff 12 | movt r9, #0xffff 13 | movw r10, #256 14 | 15 | movw sp, #0x0400 16 | push {r0, r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, ip, sp, lr, pc} 17 | bx sp 18 | 19 | _data: 20 | cmp sp, r10 21 | movlt sp, 0x400 22 | push {r0, r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, ip, sp, lr, pc} 23 | bx sp 24 | -------------------------------------------------------------------------------- /examples/r2con2021/round2/zeta.arm-32.asm: -------------------------------------------------------------------------------- 1 | _start: 2 | ldr r0, [pc, #48] 3 | ldr r1, [pc, #48] 4 | ldr r2, [pc, #48] 5 | ldr r3, [pc, #44] 6 | ldr r4, [pc, #40] 7 | ldr r5, [pc, #36] 8 | ldr r6, [pc, #36] 9 | 10 | movt r7, #0xffff 11 | movt r8, #0xffff 12 | movt r9, #0xffff 13 | movw r10, #256 14 | 15 | movw sp, #0x0400 16 | push {r0, r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, ip, sp, lr, pc} 17 | bx sp 18 | 19 | _data: 20 | cmp sp, r10 21 | movlt sp, 0x400 22 | push {r0, r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, ip, sp, lr, pc} 23 | bx sp 24 | -------------------------------------------------------------------------------- /examples/r2con2021/final/newbot.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; bc0004000089e5b860606060bb60606060b9e4ffe4ffba10fc8300be0f44e500bf606060606060606060606060ffe483fc100f44e5ebe 2 | start: 3 | mov esp, 0x400 4 | 5 | ; max bound 6 | mov eax, esp 7 | 8 | ; another code 9 | mov ecx, 0xc3c3c3c3 ; ret - i386 10 | mov edx, 0xd65f03c0 ; ret - aarch64 11 | mov ebx, 0xe12fff1e ; bx lr - arm32 12 | 13 | ; main program 14 | mov ebp, 0xe4ff6060 15 | mov esi, 0x6060e046 16 | mov edi, 0x0f60fc83 17 | 18 | ; 83fc20 - cmp esp, 0x20 19 | ; 0f46e1 - cmovbe esp, eax 20 | ; ffe4 - jmp esp 21 | 22 | pushad 23 | jmp esp -------------------------------------------------------------------------------- /csharp/Makefile: -------------------------------------------------------------------------------- 1 | VERSION=$(shell git tag|tail -n1) 2 | R2W=r2wars-$(VERSION) 3 | 4 | all: 5 | msbuild r2wars.sln 6 | 7 | run: 8 | mono bin/Release/r2wars.exe 9 | 10 | ls: 11 | $(SHELL) lsbots.sh 12 | 13 | dist: 14 | msbuild r2wars.sln /p:Configuration=Release 15 | rm -rf $(R2W) 16 | mkdir -p $(R2W) 17 | cp -rf examples bin/Release/*.exe bin/Release/*.dll $(R2W) 18 | cp -f RELEASE_README.md $(R2W)/README.txt 19 | mv $(R2W)/examples $(R2W)/warriors 20 | zip -r $(R2W).zip $(R2W) 21 | rm -rf $(R2W) 22 | 23 | r2w32: 24 | wget -c http://radare.mikelloc.com/get/2.7.0/radare2_installer-msvc_64-2.7.0.exe 25 | 26 | clean: 27 | rm -rf bin obj r2wars r2wars.zip 28 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/#/hayirlisiolsun.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; her isimizde hayirlisi olsun 2 | ; pushad loopunu 0x14 civarına unpack ettikten sonra 3 | ; oraya ziplayip 0x400'den geriye pushad yapmaya baslar 4 | ; v3: a longer pushad init 5 | pack: 6 | mov edi, 0x00000280 7 | mov esi, 0x6060fc89 8 | mov ebp, 0x60606060 9 | ; esp 10 | mov ebx, 0x60606060 11 | mov edx, 0x60606060 12 | mov ecx, 0x0400bc60 13 | mov eax, 0xeaeb0000 14 | unpack: 15 | mov esp, 0x020 16 | pushad 17 | mov dword [esp + 4 + 8], 0x60606060 18 | add esp, 0x4 ; if shorter, tune this 19 | jmp esp 20 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/goyo/flacucho.arm-32.asm: -------------------------------------------------------------------------------- 1 | ;.arch arm 2 | .bits 32 3 | 4 | .hex 00D04FE2 ; SUB SP,R15,0x00 5 | .hex FF5FBDE8 ; POP {R0-R12,R14} 6 | .hex 050D5DE3 ; r13 CMP SP,0x140 7 | .hex FFFF2DA9 ; r14 PUSHGE {R0-15} 8 | .hex FFFF2DA9 ; r12 PUSHGE 9 | .hex FFFF2DA9 ; r12 PUSHGE 10 | .hex FFFF2DA9 ; r11 PUSHGE 11 | .hex FFFF2DA9 ; r10 PUSHGE 12 | .hex 01DBA0D3 ; r9 orrle sp,r14,sp 13 | .hex 0DF0A0C1 ; r8 MOVGT R15,SP #jump if SP>=0 14 | .hex 24F05FE2 ; r6 SUBS R15,R15,0x24 15 | .hex 11111111 ; r5 16 | .hex 22222222 ; r4 17 | .hex cccccccc ; r3 18 | .hex 44444444 ; r2 19 | .hex 00040000 ; r1 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/r2con2021/final/amaterasu.x86-32.asm: -------------------------------------------------------------------------------- 1 | start: 2 | mov ebp, 0x3e0 3 | mov esp, 0x3e0 4 | ; lea eax, [end + 0x20] 5 | ; lea ebx, [start - 0x20] 6 | mov eax, 0xffffffff 7 | mov ebx, 0xffffffff 8 | mov ecx, 0xffffffff 9 | mov edx, 0xffffffff 10 | mov edi, 0xffffffff 11 | mov esi, 0xffffffff 12 | 13 | bot_loop: 14 | ; cmp esp, eax 15 | ; cmovbe esp, ebx 16 | 17 | ; push 128 bytes at once 18 | pushad 19 | pushad 20 | pushad 21 | pushad 22 | 23 | ; push again 24 | pushad 25 | pushad 26 | pushad 27 | pushad 28 | 29 | ; jmp to beginning once again 30 | cmp esp, 0x10 31 | cmovz esp, ebp 32 | jmp bot_loop 33 | 34 | end: 35 | nop -------------------------------------------------------------------------------- /examples/r2con2020/round1/lars/zutle.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; r2wars warrior by zutle 2 | ; >> So you want to play the pusha game? :D 3 | ; 4 | ; The logic below generates the following code: 5 | ; 6 | ; 7 | ;payload: 8 | ; test sp, sp 9 | ; jnz replicate 10 | ; mov sp, 0x400 11 | ;replicate: 12 | ; pushal 13 | ; pushal 14 | ; pushal 15 | ; pushal 16 | ; pushal 17 | ; pushal 18 | ; pushal 19 | ; pushal 20 | ; mov [esp + 0xc], ecx 21 | ; mov eax, esp 22 | ; jmp eax 23 | 24 | call start 25 | start: 26 | pop esp 27 | and esp, 0xffffff00 28 | add esp, 0x20 29 | mov edx, 0xe0ffe089 30 | mov ebx, 0x0c244c89 31 | mov ecx, 0x60606060 32 | mov ebp, 0x60606060 33 | mov esi, 0x0400bc66 34 | mov edi, 0x0475e485 35 | pushal 36 | mov [esp + 0xc], ecx 37 | mov eax, esp 38 | jmp eax 39 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/lars/zutle.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; r2wars warrior by zutle 2 | ; >> So you want to play the pusha game? :D 3 | ; 4 | ; The logic below generates the following code: 5 | ; 6 | ; 7 | ;payload: 8 | ; test sp, sp 9 | ; jnz replicate 10 | ; mov sp, 0x400 11 | ;replicate: 12 | ; pushal 13 | ; pushal 14 | ; pushal 15 | ; pushal 16 | ; pushal 17 | ; pushal 18 | ; pushal 19 | ; pushal 20 | ; mov [esp + 0xc], ecx 21 | ; mov eax, esp 22 | ; jmp eax 23 | 24 | call start 25 | start: 26 | pop esp 27 | and esp, 0xffffff00 28 | add esp, 0x20 29 | mov edx, 0xe0ffe089 30 | mov ebx, 0x0c244c89 31 | mov ecx, 0x60606060 32 | mov ebp, 0x60606060 33 | mov esi, 0x0400bc66 34 | mov edi, 0x0475e485 35 | pushal 36 | mov [esp + 0xc], ecx 37 | mov eax, esp 38 | jmp eax 39 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/lars/zutle.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; r2wars warrior by zutle 2 | ; >> So you want to play the pusha game? :D 3 | ; 4 | ; The logic below generates the following code: 5 | ; 6 | ; 7 | ;payload: 8 | ; test sp, sp 9 | ; jnz replicate 10 | ; mov sp, 0x400 11 | ;replicate: 12 | ; pushal 13 | ; pushal 14 | ; pushal 15 | ; pushal 16 | ; pushal 17 | ; pushal 18 | ; pushal 19 | ; pushal 20 | ; mov [esp + 0xc], ecx 21 | ; mov eax, esp 22 | ; jmp eax 23 | 24 | call start 25 | start: 26 | pop esp 27 | and esp, 0xffffff00 28 | add esp, 0x20 29 | mov edx, 0xe0ffe089 30 | mov ebx, 0x0c244c89 31 | mov ecx, 0x60606060 32 | mov ebp, 0x60606060 33 | mov esi, 0x0400bc66 34 | mov edi, 0x0475e485 35 | pushal 36 | mov [esp + 0xc], ecx 37 | mov eax, esp 38 | jmp eax 39 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/lars/zutle.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; r2wars warrior by zutle 2 | ; >> So you want to play the pusha game? :D 3 | ; 4 | ; The logic below generates the following code: 5 | ; 6 | ; 7 | ;payload: 8 | ; test sp, sp 9 | ; jnz replicate 10 | ; mov sp, 0x400 11 | ;replicate: 12 | ; pushal 13 | ; pushal 14 | ; pushal 15 | ; pushal 16 | ; pushal 17 | ; pushal 18 | ; pushal 19 | ; pushal 20 | ; mov [esp + 0xc], ecx 21 | ; mov eax, esp 22 | ; jmp eax 23 | 24 | call start 25 | start: 26 | pop esp 27 | and esp, 0xffffff00 28 | add esp, 0x20 29 | mov edx, 0xe0ffe089 30 | mov ebx, 0x0c244c89 31 | mov ecx, 0x60606060 32 | mov ebp, 0x60606060 33 | mov esi, 0x0400bc66 34 | mov edi, 0x0475e485 35 | pushal 36 | mov [esp + 0xc], ecx 37 | mov eax, esp 38 | jmp eax 39 | -------------------------------------------------------------------------------- /examples/r2con2021/final/x3ero0.arm-32.asm: -------------------------------------------------------------------------------- 1 | _start: 2 | add r14, pc, regs 3 | .hex ff3f9ee8 ; ldm r14, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, sp} 4 | 5 | x3ero0: 6 | .hex 0de01de0 ; ands lr, sp, sp 7 | .hex 0cd0e001 ; mvneq sp, ip 8 | push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15} 9 | .hex 0cd0e0e1 ; mvn sp, ip 10 | regs: 11 | mov pc, 0x3c0 12 | 13 | 14 | .hex 00000000 15 | .hex 0de01de0 16 | .hex 0cd0e001 17 | .hex ffff2de9 18 | .hex ffff2de9 19 | .hex ffff2de9 20 | .hex ffff2de9 21 | .hex ffff2de9 22 | .hex ffff2de9 23 | .hex ffff2de9 24 | .hex ffff2de9 25 | .hex 1dff2fe1 26 | .hex 10000000 27 | .hex fffbffff ; ip 28 | .hex 00040000 ; sp 29 | -------------------------------------------------------------------------------- /examples/r2con2021/round2/x3ero0.arm-64.asm: -------------------------------------------------------------------------------- 1 | _start: 2 | .hex e50325aa ; mvn x5, x5 3 | .hex e60326aa ; mvn x6, x6 4 | adr x3, loop 5 | adr x4, bot_end 6 | mov x9, 0x3d0 7 | mov x0, x3 8 | mov x1, x4 9 | loop: 10 | ; cmp x0, x4 11 | ; .hex 0020839a ; csel x0, x0, x3, cs 12 | ; cmp x1, x3 13 | ; .hex 2120849a ; csel x1, x1, x4, cs 14 | and x0, x0, x9 15 | .hex 0518bea9 ; stp x5, x6, [x0, -32]! 16 | .hex 0518bfa9 ; stp x5, x6, [x0, -16]! 17 | ; sub x0, x0, 32 18 | 19 | and x1, x1, x9 20 | .hex 251882a9 ; stp x5, x6, [x1, 32]! 21 | .hex 251881a9 ; stp x5, x6, [x1, 16]! 22 | ; sub x0, x0, 0x10 23 | ; add x1, x1, 32 24 | ; cmp x0, 0xf 25 | ; .hex 00808b9a ; csel x0, x0, x11, hi 26 | ; .hex 3fc40ff1 ; cmp x1, 0x3f1 27 | ; .hex 21308b9a ; csel x1, x1, x11, cc 28 | b loop 29 | 30 | 31 | 32 | bot_end: 33 | -------------------------------------------------------------------------------- /vlang/main.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import r2wars 4 | import flag 5 | import os 6 | 7 | fn main() { 8 | mut fp := flag.new_flag_parser(os.args[1..]) 9 | fp.application('r2wars') 10 | fp.version(r2wars.version) 11 | fp.description('battle assembly bots') 12 | fq := fp.bool('quiet', `q`, false, 'Do not show live battles') 13 | fv := fp.bool('version', `v`, false, 'Show version') 14 | fh := fp.bool('help', `h`, false, 'Show this help') 15 | if fv { 16 | println('${r2wars.version}') 17 | return 18 | } 19 | if fh { 20 | println(fp.usage()) 21 | return 22 | } 23 | mut war := r2wars.War{} 24 | botsdir := '../examples' 25 | // botsdir := '../examples/r2con2020/round1' 26 | // botsdir := 'bots' 27 | war.verbose = !fq 28 | war.load_bots(botsdir) 29 | war.fight() or { 30 | panic(err) 31 | } 32 | war.free() 33 | } 34 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/#/hayirlisiolsun.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; her isimizde hayirlisi olsun 2 | ; pushad loopunu 0x14 civarına unpack ettikten sonra 3 | ; oraya ziplayip 0x400'den geriye pushad yapmaya baslar 4 | ; v3: a longer pushad init 5 | pack: 6 | ; mov edi, 0xcccccccc 7 | ; mov esi, 0xcccccccc 8 | ; mov ebp, 0xcccccccc 9 | mov ebx, 0x00000400 10 | mov edx, 0x6060dc89 11 | mov ecx, 0x60606060 12 | mov eax, 0xf6eb6060 13 | unpack: 14 | mov esp, 0x220 15 | pushad 16 | pushad 17 | pushad 18 | pushad 19 | pushad 20 | pushad 21 | pushad 22 | pushad 23 | pushad 24 | pushad 25 | pushad 26 | pushad 27 | pushad 28 | pushad 29 | pushad 30 | pushad 31 | pushad 32 | add esp, 0x14 ; if shorter, tune this 33 | jmp esp 34 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/#/hayirlisiolsun.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; her isimizde hayirlisi olsun 2 | ; pushad loopunu 0x14 civarına unpack ettikten sonra 3 | ; oraya ziplayip 0x400'den geriye pushad yapmaya baslar 4 | ; v3: a longer pushad init 5 | pack: 6 | ; mov edi, 0xcccccccc 7 | ; mov esi, 0xcccccccc 8 | ; mov ebp, 0xcccccccc 9 | mov ebx, 0x00000400 10 | mov edx, 0x6060dc89 11 | mov ecx, 0x60606060 12 | mov eax, 0xf6eb6060 13 | unpack: 14 | mov esp, 0x220 15 | pushad 16 | pushad 17 | pushad 18 | pushad 19 | pushad 20 | pushad 21 | pushad 22 | pushad 23 | pushad 24 | pushad 25 | pushad 26 | pushad 27 | pushad 28 | pushad 29 | pushad 30 | pushad 31 | pushad 32 | add esp, 0x14 ; if shorter, tune this 33 | jmp esp 34 | -------------------------------------------------------------------------------- /examples/r2con2021/round1/x3ero0.x86-64.asm: -------------------------------------------------------------------------------- 1 | .byte 0xe8 2 | .byte 0x00 3 | .byte 0x00 4 | .byte 0x00 5 | .byte 0x00 6 | .byte 0x58 7 | .byte 0x83 8 | .byte 0xc0 9 | .byte 0x11 10 | .byte 0xb9 11 | .byte 0x00 12 | .byte 0x04 13 | .byte 0x00 14 | .byte 0x00 15 | .byte 0x48 16 | .byte 0x8d 17 | .byte 0x58 18 | .byte 0xff 19 | .byte 0x83 20 | .byte 0xc0 21 | .byte 0x20 22 | .byte 0x48 23 | .byte 0x39 24 | .byte 0xc8 25 | .byte 0x49 26 | .byte 0x0f 27 | .byte 0x43 28 | .byte 0xc6 29 | .byte 0x48 30 | .byte 0x39 31 | .byte 0xd8 32 | .byte 0x0f 33 | .byte 0x85 34 | .byte 0x03 35 | .byte 0x00 36 | .byte 0x00 37 | .byte 0x00 38 | .byte 0x83 39 | .byte 0xc0 40 | .byte 0x40 41 | .byte 0x48 42 | .byte 0x83 43 | .byte 0x38 44 | .byte 0x00 45 | .byte 0x0f 46 | .byte 0x84 47 | .byte 0xe0 48 | .byte 0xff 49 | .byte 0xff 50 | .byte 0xff 51 | .byte 0x0f 52 | .byte 0x29 53 | .byte 0x08 54 | .byte 0xe9 55 | .byte 0xd8 56 | .byte 0xff 57 | .byte 0xff 58 | .byte 0xff 59 | 60 | -------------------------------------------------------------------------------- /examples/r2con2021/round2/x3ero0.x86-64.asm: -------------------------------------------------------------------------------- 1 | .byte 0xe8 2 | .byte 0x00 3 | .byte 0x00 4 | .byte 0x00 5 | .byte 0x00 6 | .byte 0x58 7 | .byte 0x83 8 | .byte 0xc0 9 | .byte 0x11 10 | .byte 0xb9 11 | .byte 0x00 12 | .byte 0x04 13 | .byte 0x00 14 | .byte 0x00 15 | .byte 0x48 16 | .byte 0x8d 17 | .byte 0x58 18 | .byte 0xff 19 | .byte 0x83 20 | .byte 0xc0 21 | .byte 0x20 22 | .byte 0x48 23 | .byte 0x39 24 | .byte 0xc8 25 | .byte 0x49 26 | .byte 0x0f 27 | .byte 0x43 28 | .byte 0xc6 29 | .byte 0x48 30 | .byte 0x39 31 | .byte 0xd8 32 | .byte 0x0f 33 | .byte 0x85 34 | .byte 0x03 35 | .byte 0x00 36 | .byte 0x00 37 | .byte 0x00 38 | .byte 0x83 39 | .byte 0xc0 40 | .byte 0x40 41 | .byte 0x48 42 | .byte 0x83 43 | .byte 0x38 44 | .byte 0x00 45 | .byte 0x0f 46 | .byte 0x84 47 | .byte 0xe0 48 | .byte 0xff 49 | .byte 0xff 50 | .byte 0xff 51 | .byte 0x0f 52 | .byte 0x29 53 | .byte 0x08 54 | .byte 0xe9 55 | .byte 0xd8 56 | .byte 0xff 57 | .byte 0xff 58 | .byte 0xff 59 | 60 | -------------------------------------------------------------------------------- /csharp/r2wars.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "r2wars", "r2wars.csproj", "{7C07AB0A-D2B5-4546-B5B2-6DC6E77E40D1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {7C07AB0A-D2B5-4546-B5B2-6DC6E77E40D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {7C07AB0A-D2B5-4546-B5B2-6DC6E77E40D1}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {7C07AB0A-D2B5-4546-B5B2-6DC6E77E40D1}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {7C07AB0A-D2B5-4546-B5B2-6DC6E77E40D1}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/goyo/flacucho.arm-32.asm: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; bot for r2wars :: r2con2020 :: ;; 3 | ; _goyo_ ;; 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | ;.arch arm 7 | .bits 32 8 | 9 | .hex 00D04FE2 ; SUB SP,R15,0x00 10 | .hex FF5FBDE8 ; POP {R0-R12,R14} 11 | 12 | sp_top: 13 | .hex 050D5DE3 ; r0 CMP SP,0x140 14 | 15 | top_from_subs: 16 | .hex FFFF2DA9 ; r1 PUSHGE {R0-R15} 17 | .hex FFFF2DA9 ; r2 PUSHGE {R0-R15} 18 | .hex FFFF2DA9 ; r3 PUSHGE {R0-R15} 19 | .hex FFFF2DA9 ; r4 PUSHGE {R0-R15} 20 | .hex FFFF2DA9 ; r5 PUSHGE {R0-R15} 21 | .hex 01DBA0D3 ; r6 MOVLE SP,0x400 ; time to go, sp low value 22 | .hex 0DF0A0C1 ; r7 MOVGT R15,SP ; if SP>0x140 23 | .hex FFFF2DE9 ; r8 PUSH {R0-R15} ; hole starting from 0x400 24 | .hex 28F05FE2 ; r9 SUBS R15,R15,0x28 ; clear flag for pushge 25 | .hex FFFFFFFF ; r10 26 | .hex cccccccc ; r11 27 | .hex F4F4F4F4 ; r12 28 | .hex 00feffff ; r14 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/goyo/flacucho.arm-32.asm: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; bot for r2wars :: r2con2020 :: ;; 3 | ; _goyo_ ;; 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | ;.arch arm 7 | .bits 32 8 | 9 | .hex 00D04FE2 ; SUB SP,R15,0x00 10 | .hex FF5FBDE8 ; POP {R0-R12,R14} 11 | 12 | sp_top: 13 | .hex 050D5DE3 ; r0 CMP SP,0x140 14 | 15 | top_from_subs: 16 | .hex FFFF2DA9 ; r1 PUSHGE {R0-R15} 17 | .hex FFFF2DA9 ; r2 PUSHGE {R0-R15} 18 | .hex FFFF2DA9 ; r3 PUSHGE {R0-R15} 19 | .hex FFFF2DA9 ; r4 PUSHGE {R0-R15} 20 | .hex FFFF2DA9 ; r5 PUSHGE {R0-R15} 21 | .hex 01DBA0D3 ; r6 MOVLE SP,0x400 ; time to go, sp low value 22 | .hex 0DF0A0C1 ; r7 MOVGT R15,SP ; if SP>0x140 23 | .hex FFFF2DE9 ; r8 PUSH {R0-R15} ; hole starting from 0x400 24 | .hex 28F05FE2 ; r9 SUBS R15,R15,0x28 ; clear flag for pushge 25 | .hex FFFFFFFF ; r10 26 | .hex cccccccc ; r11 27 | .hex F4F4F4F4 ; r12 28 | .hex 00feffff ; r14 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/r2con2021/final/old-flacucho.arm-32.asm: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; bot for r2wars :: r2con2020 :: ;; 3 | ; _goyo_ ;; 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | .arch arm 7 | .bits 32 8 | 9 | .hex 00D04FE2 ; SUB SP,R15,0x00 10 | .hex FF5F9DE8 ; LDMFD SP,{R0-R12,R14} 11 | 12 | sp_top: 13 | .hex 050D5DE3 ; r0 CMP SP,0x140 14 | 15 | top_from_subs: 16 | .hex FFFF2DA9 ; r1 PUSHGE {R0-R15} 17 | .hex FFFF2DA9 ; r2 PUSHGE {R0-R15} 18 | .hex FFFF2DA9 ; r3 PUSHGE {R0-R15} 19 | .hex FFFF2DA9 ; r4 PUSHGE {R0-R15} 20 | .hex FFFF2DA9 ; r5 PUSHGE {R0-R15} 21 | .hex 0DF0A0C1 ; r7 MOVGT R15,SP ; if SP>0x140 22 | .hex 0ED0E0D1 ; r6 MVNLE SP,R14 ; time to go, sp low value 23 | .hex FFFF2DE9 ; r8 PUSH {R0-R15} ; hole starting from 0x400 24 | .hex 28F05FE2 ; r9 SUBS R15,R15,0x28 ; clear flag for pushge 25 | .hex FFFFFFFF ; r10 26 | .hex cccccccc ; r11 27 | .hex ccc3ccc3 ; r12 28 | .hex fffbffff ; r14 29 | -------------------------------------------------------------------------------- /examples/r2con2021/round1/old-flacucho.arm-32.asm: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; bot for r2wars :: r2con2020 :: ;; 3 | ; _goyo_ ;; 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | .arch arm 7 | .bits 32 8 | 9 | .hex 00D04FE2 ; SUB SP,R15,0x00 10 | .hex FF5F9DE8 ; LDMFD SP,{R0-R12,R14} 11 | 12 | sp_top: 13 | .hex 050D5DE3 ; r0 CMP SP,0x140 14 | 15 | top_from_subs: 16 | .hex FFFF2DA9 ; r1 PUSHGE {R0-R15} 17 | .hex FFFF2DA9 ; r2 PUSHGE {R0-R15} 18 | .hex FFFF2DA9 ; r3 PUSHGE {R0-R15} 19 | .hex FFFF2DA9 ; r4 PUSHGE {R0-R15} 20 | .hex FFFF2DA9 ; r5 PUSHGE {R0-R15} 21 | .hex 0DF0A0C1 ; r7 MOVGT R15,SP ; if SP>0x140 22 | .hex 0ED0E0D1 ; r6 MVNLE SP,R14 ; time to go, sp low value 23 | .hex FFFF2DE9 ; r8 PUSH {R0-R15} ; hole starting from 0x400 24 | .hex 28F05FE2 ; r9 SUBS R15,R15,0x28 ; clear flag for pushge 25 | .hex FFFFFFFF ; r10 26 | .hex cccccccc ; r11 27 | .hex ccc3ccc3 ; r12 28 | .hex fffbffff ; r14 29 | -------------------------------------------------------------------------------- /examples/r2con2021/round2/old-flacucho.arm-32.asm: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; bot for r2wars :: r2con2020 :: ;; 3 | ; _goyo_ ;; 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | .arch arm 7 | .bits 32 8 | 9 | .hex 00D04FE2 ; SUB SP,R15,0x00 10 | .hex FF5F9DE8 ; LDMFD SP,{R0-R12,R14} 11 | 12 | sp_top: 13 | .hex 050D5DE3 ; r0 CMP SP,0x140 14 | 15 | top_from_subs: 16 | .hex FFFF2DA9 ; r1 PUSHGE {R0-R15} 17 | .hex FFFF2DA9 ; r2 PUSHGE {R0-R15} 18 | .hex FFFF2DA9 ; r3 PUSHGE {R0-R15} 19 | .hex FFFF2DA9 ; r4 PUSHGE {R0-R15} 20 | .hex FFFF2DA9 ; r5 PUSHGE {R0-R15} 21 | .hex 0DF0A0C1 ; r7 MOVGT R15,SP ; if SP>0x140 22 | .hex 0ED0E0D1 ; r6 MVNLE SP,R14 ; time to go, sp low value 23 | .hex FFFF2DE9 ; r8 PUSH {R0-R15} ; hole starting from 0x400 24 | .hex 28F05FE2 ; r9 SUBS R15,R15,0x28 ; clear flag for pushge 25 | .hex FFFFFFFF ; r10 26 | .hex cccccccc ; r11 27 | .hex ccc3ccc3 ; r12 28 | .hex fffbffff ; r14 29 | -------------------------------------------------------------------------------- /csharp/MainModule.cs: -------------------------------------------------------------------------------- 1 | using Nancy; 2 | namespace r2warsTorneo 3 | { 4 | public class MainModule : NancyModule 5 | { 6 | public MainModule() 7 | { 8 | Get["/"] = x => View["index.html"]; 9 | } 10 | } 11 | /*public class r2warsModule : NancyModule 12 | { 13 | public r2warsModule() : base("/r2wars") 14 | { 15 | Get["/refresh"] = x => 16 | { 17 | //return r2wars.Codigo.r2wars.json_output(); 18 | return ""; 19 | }; 20 | Get["/next"] = x => 21 | { 22 | //r2wars.Codigo.r2wars.btStep_Click(); 23 | //return r2wars.Codigo.r2wars.json_output(); 24 | return ""; 25 | }; 26 | Get["/start"] = x => 27 | { 28 | //r2wars.Codigo.r2wars.btAuto_Click(); 29 | //return ""; 30 | return ""; 31 | }; 32 | Get["/reset"] = x => 33 | { 34 | //r2wars.Codigo.r2wars.btInit_Click(); 35 | //return r2wars.Codigo.r2wars.json_output(); 36 | return ""; 37 | }; 38 | } 39 | }*/ 40 | } 41 | -------------------------------------------------------------------------------- /csharp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Este código fue generado por una herramienta. 4 | // Versión de runtime:4.0.30319.42000 5 | // 6 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si 7 | // se vuelve a generar el código. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace r2warsTorneo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /csharp/Torneo/copyright.txt: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009 John Gietzen 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining 4 | // a copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to 8 | // permit persons to whom the Software is furnished to do so, subject to 9 | // the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be 12 | // included in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18 | // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE 22 | // 23 | // John Gietzen -------------------------------------------------------------------------------- /csharp/Torneo/TournamentTeamScore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// Describes the score that a team has obtained in a tournament. 5 | /// 6 | public sealed class TournamentTeamScore 7 | { 8 | /// 9 | /// Holds the team being scored. 10 | /// 11 | private readonly TournamentTeam team; 12 | 13 | /// 14 | /// Initializes a new instance of the TournamentTeamScore class. 15 | /// 16 | /// The team being scored. 17 | /// The score that the team obtained. 18 | public TournamentTeamScore(TournamentTeam team, Score score) 19 | { 20 | if (team == null) 21 | { 22 | throw new ArgumentNullException("team"); 23 | } 24 | 25 | this.team = team; 26 | this.Score = score; 27 | } 28 | 29 | /// 30 | /// Gets the team being scored. 31 | /// 32 | public TournamentTeam Team 33 | { 34 | get 35 | { 36 | return this.team; 37 | } 38 | } 39 | 40 | /// 41 | /// Gets or sets the score that the team obtained. 42 | /// 43 | public Score Score 44 | { 45 | get; 46 | set; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /csharp/Torneo/TournamentNameTable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | /// 5 | /// Encapsulates a list of the names of tournament teams. 6 | /// 7 | public sealed class TournamentNameTable 8 | { 9 | /// 10 | /// Holds the mappings of team ids to team names. 11 | /// 12 | private readonly Dictionary names; 13 | 14 | /// 15 | /// Initializes a new instance of the TournamentNameTable class, initialized with the supplied names. 16 | /// 17 | /// A pre-populated mapping of team ids to team names. 18 | public TournamentNameTable(IDictionary names) 19 | { 20 | this.names = new Dictionary(); 21 | 22 | foreach (var key in names.Keys) 23 | { 24 | this.names.Add(key, names[key]); 25 | } 26 | } 27 | 28 | /// 29 | /// Retrieves a team name associated with the supplied team id. 30 | /// 31 | /// The id of the team for which to retrieve the name. 32 | /// The team name associated with the supplied team id. 33 | public string this[long teamId] 34 | { 35 | get 36 | { 37 | return this.names[teamId]; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /csharp/Torneo/TournamentTeam.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | /// 4 | /// Describes a team that may participate in a tournament. 5 | /// 6 | [DebuggerDisplay("[Team {this.TeamId} @ {this.Rating}]")] 7 | public sealed class TournamentTeam 8 | { 9 | /// 10 | /// Holds the unique, application-specific identifier of the team. 11 | /// 12 | private readonly long teamId; 13 | 14 | /// 15 | /// Initializes a new instance of the TournamentTeam class. 16 | /// 17 | /// The unique, application-specific identifier of the team. 18 | /// The team's current rating pertaining to a specific tournament. 19 | public TournamentTeam(long teamId, int? rating) 20 | { 21 | this.teamId = teamId; 22 | this.Rating = rating; 23 | } 24 | 25 | /// 26 | /// Gets the unique, application-specific identifier of the team. 27 | /// 28 | public long TeamId 29 | { 30 | get 31 | { 32 | return this.teamId; 33 | } 34 | } 35 | 36 | /// 37 | /// Gets or sets the team's current rating or seed pertaining to a specific tournament or league. 38 | /// 39 | public int? Rating 40 | { 41 | get; 42 | set; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /RELEASE_README.md: -------------------------------------------------------------------------------- 1 | 2 | ____ ____ __ __ _ ___ _____ 3 | | _ |__ \ _| || |/' \| _ ' __/ 4 | | ( / __||_| | = | (___ \ 5 | |_|\_|____| \_/\_/|_| |_|_|\_\___/ 6 | 7 | -- skuater && pancake -- 8 | 9 | r2wars is a corewars-style game using radare2 as backend and 10 | supporting other architectures with ESIL as emulation engine. 11 | 12 | Introduction 13 | ------------ 14 | 15 | In order to start the competition you need to run r2wars.exe 16 | which is written in C# and runs on Mono, .NET/Core or MSCLR. 17 | 18 | The UI has been rewritten from the original MFC to be in HTML, 19 | so the program will run a local webserver which serves a 20 | website with few buttons to control the execution of the 21 | tournament. 22 | 23 | On Linux/Mac it will use r2 from $PATH, on Windows you need 24 | to copy `rasm2.exe` and `radare2.exe` in the same directory. 25 | 26 | Gameplay 27 | -------- 28 | 29 | Create a directory and put .asm files inside in order to load 30 | them into shared memory space allocated by r2wars. 31 | 32 | Before the `.asm` the file must specify the arch-bits setup. 33 | 34 | - .x86-32.asm for x86 32 bits warriors 35 | - .arm-32.asm for arm 32 bits warriors 36 | 37 | There must be at least 2 warriors to start the game. 38 | 39 | In case of finding warriors of more than one architecture it 40 | will prompt the user for confirmation. Because this version 41 | of r2wars allows to run programs written to run on different 42 | CPUs to be executed in the same memory address space. 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # r2wars 2 | 3 | ![Alt text](csharp/resources/r2wars_logo_transparent.png?raw=true "r2wars Logo") 4 | 5 | The C# implementation of the r2wars tournament competition 6 | 7 | Tournament api from: https://github.com/otac0n/tournaments 8 | 9 | ## Description 10 | 11 | r2wars is a game similar to corewars, where 2 programs run on a 12 | shared memory space trying to catch each other in order to trash 13 | their code and make them crash. 14 | 15 | This game was initially developed by pancake as a PoC in here 16 | 17 | * https://github.com/radare/radare2-extras/tree/master/r2wars 18 | 19 | You can refer to the r2wars For N00bs talk from r2con2020 for more information: 20 | 21 | * https://www.youtube.com/watch?v=PB0AFBqFwGQ 22 | 23 | Furthermore, you can find an explanation of the game in the first competition 24 | that happened during the 2nd r2con in 2017. 25 | 26 | * https://www.youtube.com/watch?v=sB-i5yUatx4 27 | 28 | This repository contains an evolved implementation of the engine 29 | written in C# by SkUaTeR dropping the MFC requirement that was 30 | making it impossible to run outside Windows. 31 | 32 | The solution was to use an embedded webserver that provides a 33 | web interface using websockets to stream the process changes 34 | from the M 35 | 36 | ## Dependencies 37 | 38 | * Mono / .NET Runtime (always from mono project some distros packages dont work) 39 | * radare2 40 | 41 | On windows you need to have radare2.exe and rasm2.exe in the same 42 | directory as the r2wars.exe executable. 43 | 44 | On Mac/Linux/BSD, r2wars will try to find them in the PATH. 45 | 46 | --pancake 47 | -------------------------------------------------------------------------------- /csharp/Torneo/TournamentPairing.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | /// 4 | /// Describes a pairing between one or more teams in a tournament. 5 | /// 6 | public sealed class TournamentPairing 7 | { 8 | /// 9 | /// Holds the list of team scores in the pairing. 10 | /// 11 | private readonly List teamScores; 12 | 13 | /// 14 | /// Initializes a new instance of the TournamentPairing class. 15 | /// 16 | /// The list of teams in this pairing. 17 | public TournamentPairing(IEnumerable teamScores) 18 | { 19 | this.teamScores = new List(teamScores); 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the TournamentPairing class. 24 | /// 25 | /// The parameter aray of teams in this pairing. 26 | public TournamentPairing(params TournamentTeamScore[] teamScores) 27 | { 28 | this.teamScores = new List(teamScores); 29 | } 30 | 31 | /// 32 | /// Gets a shallow read-only copy of the list of team scores in the pairing. 33 | /// 34 | public IList TeamScores 35 | { 36 | get 37 | { 38 | return this.teamScores.AsReadOnly(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/r2con2021/final/amphibia.arm-32.asm: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; bot for r2wars :: r2con2021 :: ;; 3 | ; _goyo_ ;; 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | .arch arm 7 | .bits 32 8 | 9 | 10 | .hex 08D08FE2 ; ADD SP,R15,0x08 11 | 12 | .hex FF5F9DE8 ; LDMFD SP,{R0-R12,R14} ; loading. 13 | 14 | .hex 2DB35CE0 ; SUBS R11,R12,SP, LSR #6 ; return a memory map zone value [-10 -> +6] 15 | .hex 0BF18DA0 ; ADDGE R15,SP,R11, LSL #2 ; pushes 1,2,3,4,5,or 6 or nothing, worst case when pc < 0x40 16 | start: 17 | .hex FFFF2DE9 ; r0 PUSH {R0-R15} ; 18 | .hex FFFF2DE9 ; r1 PUSH {R0-R15} ; 19 | .hex FFFF2DE9 ; r2 PUSH {R0-R15} ; 1 to 6 pushes, R11 controlled 20 | .hex FFFF2DE9 ; r3 PUSH {R0-R15} ; 21 | .hex FFFF2DE9 ; r4 PUSH {R0-R15} ; 22 | .hex FFFF2DE9 ; r5 PUSH {R0-R15} ; 23 | 24 | .hex 2DB35CE0 ; r6 SUBS R11,R12,SP, LSR #6 ; condition check 25 | .hex 0DF0A0D1 ; r7 MOVLE R15,SP ; SUBLE R15,SP,R11, LSL #6 another posibility. 26 | .hex 0BF18D20 ; r8 ADDCS R15,SP,R11, LSL #2 ; time to go, sp low value 27 | .hex 0ED0E0E1 ; r9 MVN SP,R14 ; sp = 0x400 again 28 | .hex 8CF15FC0 ; r10 SUBSGT R15,R12, LSL #3 ; back to pushes 29 | .hex 00000000 ; r11 data 30 | .hex 06000000 ; r12 data 31 | .hex fffbffff ; r14 invalid ; bad instrucction, neg(0xfffffbff) == 0x400 == stack top 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /examples/r2con2021/round1/amphibia.arm-32.asm: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; bot for r2wars :: r2con2021 :: ;; 3 | ; _goyo_ ;; 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | .arch arm 7 | .bits 32 8 | 9 | 10 | .hex 08D08FE2 ; ADD SP,R15,0x08 11 | 12 | .hex FF5F9DE8 ; LDMFD SP,{R0-R12,R14} ; loading. 13 | 14 | .hex 2DB35CE0 ; SUBS R11,R12,SP, LSR #6 ; return a memory map zone value [-10 -> +6] 15 | .hex 0BF18DA0 ; ADDGE R15,SP,R11, LSL #2 ; pushes 1,2,3,4,5,or 6 or nothing, worst case when pc < 0x40 16 | start: 17 | .hex FFFF2DE9 ; r0 PUSH {R0-R15} ; 18 | .hex FFFF2DE9 ; r1 PUSH {R0-R15} ; 19 | .hex FFFF2DE9 ; r2 PUSH {R0-R15} ; 1 to 6 pushes, R11 controlled 20 | .hex FFFF2DE9 ; r3 PUSH {R0-R15} ; 21 | .hex FFFF2DE9 ; r4 PUSH {R0-R15} ; 22 | .hex FFFF2DE9 ; r5 PUSH {R0-R15} ; 23 | 24 | .hex 2DB35CE0 ; r6 SUBS R11,R12,SP, LSR #6 ; condition check 25 | .hex 0DF0A0D1 ; r7 MOVLE R15,SP ; SUBLE R15,SP,R11, LSL #6 another posibility. 26 | .hex 0BF18D20 ; r8 ADDCS R15,SP,R11, LSL #2 ; time to go, sp low value 27 | .hex 0ED0E0E1 ; r9 MVN SP,R14 ; sp = 0x400 again 28 | .hex 8CF15FC0 ; r10 SUBSGT R15,R12, LSL #3 ; back to pushes 29 | .hex 00000000 ; r11 data 30 | .hex 06000000 ; r12 data 31 | .hex fffbffff ; r14 invalid ; bad instrucction, neg(0xfffffbff) == 0x400 == stack top 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /examples/r2con2021/round2/amphibia.arm-32.asm: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; bot for r2wars :: r2con2021 :: ;; 3 | ; _goyo_ ;; 4 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 5 | 6 | .arch arm 7 | .bits 32 8 | 9 | 10 | .hex 08D08FE2 ; ADD SP,R15,0x08 11 | 12 | .hex FF5F9DE8 ; LDMFD SP,{R0-R12,R14} ; loading. 13 | 14 | .hex 2DB35CE0 ; SUBS R11,R12,SP, LSR #6 ; return a memory map zone value [-10 -> +6] 15 | .hex 0BF18DA0 ; ADDGE R15,SP,R11, LSL #2 ; pushes 1,2,3,4,5,or 6 or nothing, worst case when pc < 0x40 16 | start: 17 | .hex FFFF2DE9 ; r0 PUSH {R0-R15} ; 18 | .hex FFFF2DE9 ; r1 PUSH {R0-R15} ; 19 | .hex FFFF2DE9 ; r2 PUSH {R0-R15} ; 1 to 6 pushes, R11 controlled 20 | .hex FFFF2DE9 ; r3 PUSH {R0-R15} ; 21 | .hex FFFF2DE9 ; r4 PUSH {R0-R15} ; 22 | .hex FFFF2DE9 ; r5 PUSH {R0-R15} ; 23 | 24 | .hex 2DB35CE0 ; r6 SUBS R11,R12,SP, LSR #6 ; condition check 25 | .hex 0DF0A0D1 ; r7 MOVLE R15,SP ; SUBLE R15,SP,R11, LSL #6 another posibility. 26 | .hex 0BF18D20 ; r8 ADDCS R15,SP,R11, LSL #2 ; time to go, sp low value 27 | .hex 0ED0E0E1 ; r9 MVN SP,R14 ; sp = 0x400 again 28 | .hex 8CF15FC0 ; r10 SUBSGT R15,R12, LSL #3 ; back to pushes 29 | .hex 00000000 ; r11 data 30 | .hex 06000000 ; r12 data 31 | .hex fffbffff ; r14 invalid ; bad instrucction, neg(0xfffffbff) == 0x400 == stack top 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /csharp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // La información general de un ensamblado se controla mediante el siguiente 6 | // conjunto de atributos. Cambie estos valores de atributo para modificar la información 7 | // asociada con un ensamblado. 8 | [assembly: AssemblyTitle("WindowsFormsApplication1")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WindowsFormsApplication1")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles 18 | // para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde 19 | // COM, establezca el atributo ComVisible en true en este tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM. 23 | [assembly: Guid("7c07ab0a-d2b5-4546-b5b2-6dc6e77e40d1")] 24 | 25 | // La información de versión de un ensamblado consta de los cuatro valores siguientes: 26 | // 27 | // Versión principal 28 | // Versión secundaria 29 | // Número de compilación 30 | // Revisión 31 | // 32 | // Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión 33 | // mediante el carácter '*', como se muestra a continuación: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/ThirdPartyNotices.txt: -------------------------------------------------------------------------------- 1 | This Microsoft .NET Library may incorporate components from the projects listed 2 | below. Microsoft licenses these components under the Microsoft .NET Library 3 | software license terms. The original copyright notices and the licenses under 4 | which Microsoft received such components are set forth below for informational 5 | purposes only. Microsoft reserves all rights not expressly granted herein, 6 | whether by implication, estoppel or otherwise. 7 | 8 | 1. .NET Core (https://github.com/dotnet/core/) 9 | 10 | .NET Core 11 | Copyright (c) .NET Foundation and Contributors 12 | 13 | The MIT License (MIT) 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy 16 | of this software and associated documentation files (the "Software"), to deal 17 | in the Software without restriction, including without limitation the rights 18 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | copies of the Software, and to permit persons to whom the Software is 20 | furnished to do so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. -------------------------------------------------------------------------------- /examples/r2con2020/round4/#/hayirlisiolsun.x86-32_comments.asm: -------------------------------------------------------------------------------- 1 | ; "her isimizde hayirlisi olsun" 2 | 3 | ; a replicator bot. This one unpacks it's main loop payload 4 | ; around 0xc and jumps to there. In the loop, it first fills 5 | ; upper half of the arena then bottom half of the arena using 6 | ; pushad's. 7 | ; 8 | ; v1: initial; pushad from 0x400 through 0x0 result: 5 of 9 9 | ; v2: I don't remember not competed 10 | ; v3: a longer pushad sequence in init phase for quickscoping result: 5 of 13 && 8 of 14 11 | ; v4: the longest packed loop using all registers for just tryin'. result: 10 of 15 12 | ; 13 | ; 14 | ; pack contents are below 15 | ;;;;;;;;;;;;;;;;;;;;;;;;;; 16 | ; mov esp, edi 17 | ; loop: 18 | ; pushad 19 | ; pushad 20 | ; pushad 21 | ; pushad 22 | ; pushad 23 | ; pushad 24 | ; pushad 25 | ; pushad 26 | ; pushad 27 | ; pushad 28 | ; pushad 29 | ; pushad 30 | ; pushad 31 | ; pushad 32 | ; pushad 33 | ; mov esp, 0x400 34 | ; jmp loop 35 | 36 | pack: 37 | mov edi, 0x00000280 38 | mov esi, 0x6060fc89 39 | mov ebp, 0x60606060 40 | ; esp popped here as 0x20 (a bad instruction). must be corrected in unpack loop 41 | mov ebx, 0x60606060 42 | mov edx, 0x60606060 43 | mov ecx, 0x0400bc60 44 | mov eax, 0xeaeb0000 45 | unpack: 46 | mov esp, 0x020 47 | pushad 48 | mov dword [esp + 4 + 8], 0x60606060 ; fix popped esp value 49 | add esp, 0x4 ; tune this according to pack length 50 | jmp esp 51 | -------------------------------------------------------------------------------- /csharp/Torneo/TournamentRound.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | /// 5 | /// Describes a round within a tournament which consists of one or more pairings. 6 | /// 7 | public sealed class TournamentRound 8 | { 9 | /// 10 | /// Holds the list of pairings in the round. 11 | /// 12 | private readonly List pairings; 13 | 14 | /// 15 | /// Initializes a new instance of the TournamentRound class. 16 | /// 17 | /// The list of pairings in the round. 18 | public TournamentRound(IEnumerable pairings) 19 | { 20 | if (pairings == null) 21 | { 22 | throw new ArgumentNullException("pairings"); 23 | } 24 | 25 | this.pairings = new List(pairings); 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of the TournamentRound class. 30 | /// 31 | /// The parameter array of pairings in the round. 32 | public TournamentRound(params TournamentPairing[] pairings) 33 | { 34 | if (pairings == null) 35 | { 36 | throw new ArgumentNullException("pairings"); 37 | } 38 | 39 | this.pairings = new List(pairings); 40 | } 41 | 42 | /// 43 | /// Gets a shallow read-only copy of the list of pairings in the round. 44 | /// 45 | public IList Pairings 46 | { 47 | get 48 | { 49 | return this.pairings.AsReadOnly(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /csharp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using WebSocketSharp.Server; 6 | namespace r2warsTorneo 7 | { 8 | static public class r2warsStatic 9 | { 10 | static public r2wars r2w = new r2wars(); 11 | static public Torneo torneo = new Torneo(); 12 | } 13 | class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | string httpUrl = "http://0.0.0.0:9664"; 18 | string websocketUrl = "ws://0.0.0.0:9966"; 19 | if (OperatingSystem.IsWindows()) 20 | { 21 | httpUrl = "http://127.0.0.1:9664"; 22 | websocketUrl = "ws://127.0.0.1:9966"; 23 | } 24 | var tokenSource = new CancellationTokenSource(); 25 | CancellationToken ct = tokenSource.Token; 26 | if (args.Length > 0) { 27 | r2warsStatic.torneo.SetWarriorsDirectory(args[0]); 28 | } 29 | 30 | var taskA = new Task(() => 31 | { 32 | var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri(httpUrl), new CustomBootstrapper()); 33 | nancyHost.Start(); 34 | Console.WriteLine("Web server running at " + httpUrl); 35 | 36 | Process.Start(httpUrl); 37 | 38 | 39 | while (!ct.IsCancellationRequested) { Thread.Sleep(1000); } 40 | nancyHost.Stop(); 41 | }, tokenSource.Token); 42 | 43 | var taskB = new Task(() => 44 | { 45 | var wssv = new WebSocketServer(websocketUrl); 46 | wssv.AddWebSocketService("/r2wars"); 47 | wssv.Start(); 48 | while (!ct.IsCancellationRequested) { Thread.Sleep(1000); } 49 | wssv.Stop(); 50 | }, tokenSource.Token); 51 | 52 | taskA.Start(); 53 | taskB.Start(); 54 | Console.ReadKey(); 55 | tokenSource.Cancel(); 56 | 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /csharp/Torneo/TournamentRanking.cs: -------------------------------------------------------------------------------- 1 | /// 2 | /// Describes the position of a team in a tournament's rankings. 3 | /// 4 | public sealed class TournamentRanking 5 | { 6 | /// 7 | /// Holds the team being ranked. 8 | /// 9 | private readonly TournamentTeam team; 10 | 11 | /// 12 | /// Holds the rank number of the ranking. 13 | /// 14 | private readonly double rank; 15 | 16 | /// 17 | /// Holds the score description or justification of the ranking. 18 | /// 19 | private readonly string scoreDescription; 20 | 21 | /// 22 | /// Initializes a new instance of the TournamentRanking class. 23 | /// 24 | /// The team being ranked. 25 | /// The actual rank number of the ranking. 26 | /// The score description or justification of the ranking. 27 | public TournamentRanking(TournamentTeam team, double rank, string scoreDescription) 28 | { 29 | this.team = team; 30 | this.rank = rank; 31 | this.scoreDescription = scoreDescription; 32 | } 33 | 34 | /// 35 | /// Gets the team being ranked. 36 | /// 37 | public TournamentTeam Team 38 | { 39 | get 40 | { 41 | return this.team; 42 | } 43 | } 44 | 45 | /// 46 | /// Gets the rank number of the ranking. 47 | /// 48 | public double Rank 49 | { 50 | get 51 | { 52 | return this.rank; 53 | } 54 | } 55 | 56 | /// 57 | /// Gets the score description or justification of the ranking. 58 | /// 59 | public string ScoreDescription 60 | { 61 | get 62 | { 63 | return this.scoreDescription; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /warriors/FATbanana.x86-32.asm: -------------------------------------------------------------------------------- 1 | call init 2 | 3 | syscall 4 | syscall 5 | syscall 6 | syscall 7 | syscall 8 | syscall 9 | syscall 10 | syscall 11 | syscall 12 | syscall 13 | syscall 14 | syscall 15 | syscall 16 | syscall 17 | syscall 18 | syscall 19 | syscall 20 | syscall 21 | syscall 22 | syscall 23 | syscall 24 | syscall 25 | syscall 26 | syscall 27 | syscall 28 | syscall 29 | syscall 30 | syscall 31 | syscall 32 | syscall 33 | syscall 34 | syscall 35 | syscall 36 | syscall 37 | syscall 38 | syscall 39 | syscall 40 | syscall 41 | syscall 42 | syscall 43 | syscall 44 | syscall 45 | syscall 46 | syscall 47 | syscall 48 | syscall 49 | syscall 50 | syscall 51 | syscall 52 | syscall 53 | syscall 54 | syscall 55 | syscall 56 | syscall 57 | syscall 58 | syscall 59 | syscall 60 | syscall 61 | syscall 62 | syscall 63 | syscall 64 | syscall 65 | syscall 66 | syscall 67 | syscall 68 | syscall 69 | syscall 70 | syscall 71 | syscall 72 | syscall 73 | 74 | init: 75 | mov eax, 0x340 76 | mov ebx, 0xc3c3c3c3 77 | mov ecx, ebx ; trash 78 | mov edx, 0x400 ; end of arena 79 | 80 | mov edi, 0xd439c401 81 | mov esi, 0x60e04f0f 82 | mov ebp, 0xe4ff6060 83 | 84 | call yolo_1 85 | 86 | syscall 87 | syscall 88 | syscall 89 | syscall 90 | syscall 91 | syscall 92 | syscall 93 | syscall 94 | syscall 95 | syscall 96 | syscall 97 | syscall 98 | syscall 99 | syscall 100 | syscall 101 | syscall 102 | syscall 103 | syscall 104 | syscall 105 | syscall 106 | syscall 107 | syscall 108 | syscall 109 | syscall 110 | syscall 111 | syscall 112 | syscall 113 | syscall 114 | syscall 115 | syscall 116 | syscall 117 | syscall 118 | syscall 119 | syscall 120 | 121 | yolo_1: 122 | mov esp, 0x210 123 | pushad 124 | mov esp, 0x66 125 | pushad 126 | mov esp, 0x3f9 127 | pushad 128 | call yolo_2 129 | 130 | syscall 131 | syscall 132 | syscall 133 | syscall 134 | syscall 135 | syscall 136 | syscall 137 | syscall 138 | syscall 139 | syscall 140 | syscall 141 | syscall 142 | syscall 143 | syscall 144 | syscall 145 | syscall 146 | syscall 147 | 148 | yolo_2: 149 | mov esp, eax ; relocate to `eax` 150 | pushad 151 | pushad 152 | mov eax, 0x99 ; first address after reloc 153 | jmp esp 154 | 155 | syscall 156 | syscall 157 | syscall 158 | syscall 159 | syscall 160 | syscall 161 | syscall 162 | syscall 163 | syscall 164 | syscall 165 | syscall 166 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/CaptnBanana/FATbanana.x86-32.asm: -------------------------------------------------------------------------------- 1 | call init 2 | 3 | syscall 4 | syscall 5 | syscall 6 | syscall 7 | syscall 8 | syscall 9 | syscall 10 | syscall 11 | syscall 12 | syscall 13 | syscall 14 | syscall 15 | syscall 16 | syscall 17 | syscall 18 | syscall 19 | syscall 20 | syscall 21 | syscall 22 | syscall 23 | syscall 24 | syscall 25 | syscall 26 | syscall 27 | syscall 28 | syscall 29 | syscall 30 | syscall 31 | syscall 32 | syscall 33 | syscall 34 | syscall 35 | syscall 36 | syscall 37 | syscall 38 | syscall 39 | syscall 40 | syscall 41 | syscall 42 | syscall 43 | syscall 44 | syscall 45 | syscall 46 | syscall 47 | syscall 48 | syscall 49 | syscall 50 | syscall 51 | syscall 52 | syscall 53 | syscall 54 | syscall 55 | syscall 56 | syscall 57 | syscall 58 | syscall 59 | syscall 60 | syscall 61 | syscall 62 | syscall 63 | syscall 64 | syscall 65 | syscall 66 | syscall 67 | syscall 68 | syscall 69 | syscall 70 | syscall 71 | syscall 72 | syscall 73 | 74 | init: 75 | mov eax, 0x340 76 | mov ebx, 0xc3c3c3c3 77 | mov ecx, ebx ; trash 78 | mov edx, 0x400 ; end of arena 79 | 80 | mov edi, 0xd439c401 81 | mov esi, 0x60e04f0f 82 | mov ebp, 0xe4ff6060 83 | 84 | call yolo_1 85 | 86 | syscall 87 | syscall 88 | syscall 89 | syscall 90 | syscall 91 | syscall 92 | syscall 93 | syscall 94 | syscall 95 | syscall 96 | syscall 97 | syscall 98 | syscall 99 | syscall 100 | syscall 101 | syscall 102 | syscall 103 | syscall 104 | syscall 105 | syscall 106 | syscall 107 | syscall 108 | syscall 109 | syscall 110 | syscall 111 | syscall 112 | syscall 113 | syscall 114 | syscall 115 | syscall 116 | syscall 117 | syscall 118 | syscall 119 | syscall 120 | 121 | yolo_1: 122 | mov esp, 0x210 123 | pushad 124 | mov esp, 0x66 125 | pushad 126 | mov esp, 0x3f9 127 | pushad 128 | call yolo_2 129 | 130 | syscall 131 | syscall 132 | syscall 133 | syscall 134 | syscall 135 | syscall 136 | syscall 137 | syscall 138 | syscall 139 | syscall 140 | syscall 141 | syscall 142 | syscall 143 | syscall 144 | syscall 145 | syscall 146 | syscall 147 | 148 | yolo_2: 149 | mov esp, eax ; relocate to `eax` 150 | pushad 151 | pushad 152 | mov eax, 0x99 ; first address after reloc 153 | jmp esp 154 | 155 | syscall 156 | syscall 157 | syscall 158 | syscall 159 | syscall 160 | syscall 161 | syscall 162 | syscall 163 | syscall 164 | syscall 165 | syscall 166 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/CaptnBanana/FATbanana.x86-32.asm: -------------------------------------------------------------------------------- 1 | call init 2 | 3 | syscall 4 | syscall 5 | syscall 6 | syscall 7 | syscall 8 | syscall 9 | syscall 10 | syscall 11 | syscall 12 | syscall 13 | syscall 14 | syscall 15 | syscall 16 | syscall 17 | syscall 18 | syscall 19 | syscall 20 | syscall 21 | syscall 22 | syscall 23 | syscall 24 | syscall 25 | syscall 26 | syscall 27 | syscall 28 | syscall 29 | syscall 30 | syscall 31 | syscall 32 | syscall 33 | syscall 34 | syscall 35 | syscall 36 | syscall 37 | syscall 38 | syscall 39 | syscall 40 | syscall 41 | syscall 42 | syscall 43 | syscall 44 | syscall 45 | syscall 46 | syscall 47 | syscall 48 | syscall 49 | syscall 50 | syscall 51 | syscall 52 | syscall 53 | syscall 54 | syscall 55 | syscall 56 | syscall 57 | syscall 58 | syscall 59 | syscall 60 | syscall 61 | syscall 62 | syscall 63 | syscall 64 | syscall 65 | syscall 66 | syscall 67 | syscall 68 | syscall 69 | syscall 70 | syscall 71 | syscall 72 | syscall 73 | 74 | init: 75 | mov eax, 0x340 76 | mov ebx, 0xc3c3c3c3 77 | mov ecx, ebx ; trash 78 | mov edx, 0x400 ; end of arena 79 | 80 | mov edi, 0xd439c401 81 | mov esi, 0x60e04f0f 82 | mov ebp, 0xe4ff6060 83 | 84 | call yolo_1 85 | 86 | syscall 87 | syscall 88 | syscall 89 | syscall 90 | syscall 91 | syscall 92 | syscall 93 | syscall 94 | syscall 95 | syscall 96 | syscall 97 | syscall 98 | syscall 99 | syscall 100 | syscall 101 | syscall 102 | syscall 103 | syscall 104 | syscall 105 | syscall 106 | syscall 107 | syscall 108 | syscall 109 | syscall 110 | syscall 111 | syscall 112 | syscall 113 | syscall 114 | syscall 115 | syscall 116 | syscall 117 | syscall 118 | syscall 119 | syscall 120 | 121 | yolo_1: 122 | mov esp, 0x210 123 | pushad 124 | mov esp, 0x66 125 | pushad 126 | mov esp, 0x3f9 127 | pushad 128 | call yolo_2 129 | 130 | syscall 131 | syscall 132 | syscall 133 | syscall 134 | syscall 135 | syscall 136 | syscall 137 | syscall 138 | syscall 139 | syscall 140 | syscall 141 | syscall 142 | syscall 143 | syscall 144 | syscall 145 | syscall 146 | syscall 147 | 148 | yolo_2: 149 | mov esp, eax ; relocate to `eax` 150 | pushad 151 | pushad 152 | mov eax, 0x99 ; first address after reloc 153 | jmp esp 154 | 155 | syscall 156 | syscall 157 | syscall 158 | syscall 159 | syscall 160 | syscall 161 | syscall 162 | syscall 163 | syscall 164 | syscall 165 | syscall 166 | -------------------------------------------------------------------------------- /csharp/CustomBootstrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using Nancy; 5 | using Nancy.Bootstrapper; 6 | using Nancy.Responses; 7 | using Nancy.Session; 8 | using Nancy.ViewEngines; 9 | using Nancy.TinyIoc; 10 | namespace r2warsTorneo 11 | { 12 | public class CustomBootstrapper : DefaultNancyBootstrapper 13 | { 14 | protected override void ConfigureApplicationContainer(TinyIoCContainer container) 15 | { 16 | base.ConfigureApplicationContainer(container); 17 | ResourceViewLocationProvider.RootNamespaces.Add(Assembly.GetAssembly(typeof(MainModule)), "r2warsTorneo.Views"); 18 | } 19 | 20 | protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) 21 | { 22 | base.ApplicationStartup(container, pipelines); 23 | CookieBasedSessions.Enable(pipelines); 24 | } 25 | 26 | /*protected override void ConfigureConventions(NancyConventions conventions) 27 | { 28 | base.ConfigureConventions(conventions); 29 | conventions.StaticContentsConventions.Add(AddStaticResourcePath("/content", Assembly.GetAssembly(typeof(MainModule)), "r2wars.Web.Views.content")); 30 | }*/ 31 | 32 | protected override NancyInternalConfiguration InternalConfiguration 33 | { 34 | get 35 | { 36 | return NancyInternalConfiguration.WithOverrides(OnConfigurationBuilder); 37 | } 38 | } 39 | 40 | void OnConfigurationBuilder(NancyInternalConfiguration x) 41 | { 42 | x.ViewLocationProvider = typeof(ResourceViewLocationProvider); 43 | } 44 | protected override byte[] FavIcon 45 | { 46 | get { return null; } 47 | } 48 | public static Func AddStaticResourcePath(string requestedPath, Assembly assembly, string namespacePrefix) 49 | { 50 | return (context, s) => 51 | { 52 | var path = context.Request.Path; 53 | if (!path.StartsWith(requestedPath)) 54 | { 55 | return null; 56 | } 57 | 58 | string resourcePath; 59 | string name; 60 | 61 | var adjustedPath = path.Substring(requestedPath.Length + 1); 62 | if (adjustedPath.IndexOf('/') >= 0) 63 | { 64 | name = Path.GetFileName(adjustedPath); 65 | resourcePath = namespacePrefix + "." + adjustedPath.Substring(0, adjustedPath.Length - name.Length - 1).Replace('/', '.'); 66 | } 67 | else 68 | { 69 | name = adjustedPath; 70 | resourcePath = namespacePrefix; 71 | } 72 | return new EmbeddedFileResponse(assembly, resourcePath, name); 73 | }; 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /csharp/Torneo/InvalidTournamentStateException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// Thrown when an IPairingsGenerator is asked to load a state that does not represent a valid tournament within its constraints. 5 | /// 6 | [global::System.Serializable] 7 | public class InvalidTournamentStateException : Exception 8 | { 9 | /// 10 | /// Initializes a new instance of the InvalidTournamentStateException class. 11 | /// 12 | public InvalidTournamentStateException() 13 | { 14 | } 15 | 16 | /// 17 | /// Initializes a new instance of the InvalidTournamentStateException class with a specified error message. 18 | /// 19 | /// The message that describes the error. 20 | public InvalidTournamentStateException(string message) 21 | : base(message) 22 | { 23 | } 24 | 25 | /// 26 | /// Initializes a new instance of the InvalidTournamentStateException class with a specified error 27 | /// message and a reference to the inner exception that is the cause of this exception. 28 | /// 29 | /// The message that describes the error. 30 | /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. 31 | public InvalidTournamentStateException(string message, Exception inner) 32 | : base(message, inner) 33 | { 34 | } 35 | 36 | /// 37 | /// Initializes a new instance of the InvalidTournamentStateException class with serialized data. 38 | /// 39 | /// The System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown. 40 | /// The System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination. 41 | /// The info parameter is null. 42 | /// The class name is null or System.Exception.HResult is zero (0). 43 | protected InvalidTournamentStateException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) 44 | : base(info, context) 45 | { 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /csharp/r2warsWebSocket.cs: -------------------------------------------------------------------------------- 1 | using WebSocketSharp; 2 | using WebSocketSharp.Server; 3 | namespace r2warsTorneo 4 | { 5 | public class r2warsWebSocket : WebSocketBehavior 6 | { 7 | static MyHandler1 h1; 8 | protected override void OnMessage(MessageEventArgs e) 9 | { 10 | string recv = e.Data; 11 | string msg = ""; 12 | if (recv == "cmd_prevlog") 13 | { 14 | r2warsStatic.r2w.prevLog(); 15 | } 16 | else if (recv == "cmd_nextlog") 17 | { 18 | r2warsStatic.r2w.nextLog(); 19 | } 20 | else if (recv == "cmd_load") 21 | { 22 | r2warsStatic.torneo.LoadTournamentPlayers(); 23 | } 24 | else if (recv == "cmd_run") 25 | { 26 | r2warsStatic.torneo.RunTournamentCombats(); 27 | } 28 | else if (recv == "cmd_stop") 29 | { 30 | r2warsStatic.torneo.StopActualCombat(); 31 | } 32 | else if (recv == "cmd_next") 33 | { 34 | r2warsStatic.torneo.StepTournamentCombats(); 35 | } 36 | else if (recv == "cmd_dbg4") 37 | { 38 | r2warsStatic.r2w.bStopAtRoundStart = false; 39 | } 40 | else if (recv == "cmd_dbg4si") 41 | { 42 | r2warsStatic.r2w.bStopAtRoundStart = true; 43 | } 44 | else if (recv == "cmd_dbg5") 45 | { 46 | r2warsStatic.r2w.bStopAtRoundEnd = false; 47 | } 48 | else if (recv == "cmd_dbg5si") 49 | { 50 | r2warsStatic.r2w.bStopAtRoundEnd = true; 51 | } 52 | else if (recv == "moreflow") 53 | { 54 | r2warsStatic.r2w.sync_var = true; 55 | msg = "none"; 56 | } 57 | else if (recv == "arch_arm") 58 | { 59 | r2warsStatic.r2w.answer = "arm"; 60 | } 61 | else if (recv == "arch_x86") 62 | { 63 | r2warsStatic.r2w.answer = "x86"; 64 | } 65 | if (msg!="") 66 | Send(msg); 67 | } 68 | private void R2wars_EventPinta(object sender, MyEvent e) 69 | { 70 | r2warsStatic.r2w.sync_var = false; 71 | Send(e.message); 72 | } 73 | protected override void OnError(ErrorEventArgs e) 74 | { 75 | base.OnError(e); 76 | } 77 | 78 | protected override void OnClose(CloseEventArgs e) 79 | { 80 | r2warsStatic.r2w.Event_draw -= h1; 81 | base.OnClose(e); 82 | } 83 | protected override void OnOpen() 84 | { 85 | //r2warsStatic.r2w.Event_draw -= h1; 86 | h1 = new MyHandler1(R2wars_EventPinta); 87 | r2warsStatic.r2w.Event_draw += h1; 88 | base.OnOpen(); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /examples/r2con2021/round1/30-09-2021 21-10-04.r2wars.txt: -------------------------------------------------------------------------------- 1 | RANKING 2 | ============== 3 | Combat 6 / 6 4 | 5 | 1 amphibia.arm-32 3,00 (3-0-0 with 6 overall). 6 | 2 old-flacucho.arm-32 2,00 (2-0-1 with 5 overall). 7 | 3 ricardoapl.x86-32 1,00 (1-0-2 with 2 overall). 8 | 4 x3ero0.x86-64 0,00 (0-0-3 with 0 overall). 9 | 10 | FULL LOG 11 | ============== 12 | Tournament start 30/09/2021 21:09:02 13 | Combat initialized 1 amphibia.arm-32 vs old-flacucho.arm-32 14 | Round-1 old-flacucho.arm-32 Wins Cycles:39 15 | Dead Reason : Executed invalid instruction 16 | Dead Instruction: 0x000000d8 invalid 17 | Round-2 amphibia.arm-32 Wins Cycles:51 18 | Dead Reason : Executed invalid instruction 19 | Dead Instruction: 0x00000130 invalid 20 | Round-3 amphibia.arm-32 Wins Cycles:135 21 | Dead Reason : Executed invalid instruction 22 | Dead Instruction: 0x00000078 invalid 23 | Combat Winner: amphibia.arm-32 24 | Combat initialized 2 ricardoapl.x86-32 vs x3ero0.x86-64 25 | Round-1 ricardoapl.x86-32 Wins Cycles:42 26 | Dead Reason : Executed invalid instruction 27 | Dead Instruction: 0x000001e6 invalid 28 | Round-2 ricardoapl.x86-32 Wins Cycles:291 29 | Dead Reason : Executed invalid instruction out of ARENA 30 | Dead Instruction: 0xffffffff83000264 invalid 31 | Combat Winner: ricardoapl.x86-32 32 | Combat initialized 3 amphibia.arm-32 vs ricardoapl.x86-32 33 | Round-1 amphibia.arm-32 Wins Cycles:40 34 | Dead Reason : Instruction Read/Write out of ARENA. 35 | Dead Instruction: 0x000001ae add byte [eax], al 36 | Round-2 amphibia.arm-32 Wins Cycles:39 37 | Dead Reason : Instruction Read/Write out of ARENA. 38 | Dead Instruction: 0x000001ed add al, byte [eax] 39 | Combat Winner: amphibia.arm-32 40 | Combat initialized 4 old-flacucho.arm-32 vs x3ero0.x86-64 41 | Round-1 old-flacucho.arm-32 Wins Cycles:106 42 | Dead Reason : Instruction Read/Write out of ARENA. 43 | Dead Instruction: 0x000001bf add byte [0xffffffffffe35ed2], al 44 | Round-2 old-flacucho.arm-32 Wins Cycles:35 45 | Dead Reason : Executed invalid instruction 46 | Dead Instruction: 0x0000027c invalid 47 | Combat Winner: old-flacucho.arm-32 48 | Combat initialized 5 amphibia.arm-32 vs x3ero0.x86-64 49 | Round-1 amphibia.arm-32 Wins Cycles:86 50 | Dead Reason : Syscall/Int Instruction executed. 51 | Dead Instruction: 0x000002a1 int1 52 | Round-2 amphibia.arm-32 Wins Cycles:85 53 | Dead Reason : Syscall/Int Instruction executed. 54 | Dead Instruction: 0x000002a1 int1 55 | Combat Winner: amphibia.arm-32 56 | Combat initialized 6 old-flacucho.arm-32 vs ricardoapl.x86-32 57 | Round-1 old-flacucho.arm-32 Wins Cycles:94 58 | Dead Reason : Instruction Read/Write out of ARENA. 59 | Dead Instruction: 0x00000189 jmp [0x2dffffa9] 60 | Round-2 old-flacucho.arm-32 Wins Cycles:51 61 | Dead Reason : Executed invalid instruction 62 | Dead Instruction: 0x000001e8 invalid 63 | Combat Winner: old-flacucho.arm-32 64 | Tournament end 30/09/2021 21:10:04 65 | -------------------------------------------------------------------------------- /csharp/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Este código fue generado por una herramienta. 4 | // Versión de runtime:4.0.30319.42000 5 | // 6 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si 7 | // se vuelve a generar el código. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace r2warsTorneo.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc. 17 | /// 18 | // StronglyTypedResourceBuilder generó automáticamente esta clase 19 | // a través de una herramienta como ResGen o Visual Studio. 20 | // Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen 21 | // con la opción /str o recompile su proyecto de VS. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("r2warsTorneo.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las 51 | /// búsquedas de recursos mediante esta clase de recurso fuertemente tipado. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /examples/r2con2021/round1/30-09-2021 21-11-53.r2wars.txt: -------------------------------------------------------------------------------- 1 | RANKING 2 | ============== 3 | Combat 6 / 6 4 | 5 | 1 old-flacucho.arm-32 3,00 (3-0-0 with 6 overall). 6 | 2 ricardoapl.x86-32 2,00 (2-0-1 with 4 overall). 7 | 3 amphibia.arm-32 1,00 (1-0-2 with 3 overall). 8 | 4 x3ero0.x86-64 0,00 (0-0-3 with 0 overall). 9 | 10 | FULL LOG 11 | ============== 12 | Tournament start 30/09/2021 21:10:51 13 | Combat initialized 1 amphibia.arm-32 vs old-flacucho.arm-32 14 | Round-1 amphibia.arm-32 Wins Cycles:72 15 | Dead Reason : Executed invalid instruction 16 | Dead Instruction: 0x00000064 invalid 17 | Round-2 old-flacucho.arm-32 Wins Cycles:98 18 | Dead Reason : Instruction Read/Write out of ARENA. 19 | Dead Instruction: 0x00000204 pushge {r0, r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, ip, sp, lr, pc} 20 | Round-3 old-flacucho.arm-32 Wins Cycles:46 21 | Dead Reason : Instruction Read/Write out of ARENA. 22 | Dead Instruction: 0x00000164 pushge {r0, r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, ip, sp, lr, pc} 23 | Combat Winner: old-flacucho.arm-32 24 | Combat initialized 2 ricardoapl.x86-32 vs x3ero0.x86-64 25 | Round-1 ricardoapl.x86-32 Wins Cycles:220 26 | Dead Reason : Executed invalid instruction 27 | Dead Instruction: 0x00000354 invalid 28 | Round-2 ricardoapl.x86-32 Wins Cycles:91 29 | Dead Reason : Executed invalid instruction 30 | Dead Instruction: 0x00000138 invalid 31 | Combat Winner: ricardoapl.x86-32 32 | Combat initialized 3 amphibia.arm-32 vs ricardoapl.x86-32 33 | Round-1 ricardoapl.x86-32 Wins Cycles:57 34 | Dead Reason : Executed invalid instruction 35 | Dead Instruction: 0x000001d4 invalid 36 | Round-2 ricardoapl.x86-32 Wins Cycles:58 37 | Dead Reason : Executed invalid instruction 38 | Dead Instruction: 0x000001a8 invalid 39 | Combat Winner: ricardoapl.x86-32 40 | Combat initialized 4 old-flacucho.arm-32 vs x3ero0.x86-64 41 | Round-1 old-flacucho.arm-32 Wins Cycles:108 42 | Dead Reason : Executed invalid instruction 43 | Dead Instruction: 0x000002ba invalid 44 | Round-2 old-flacucho.arm-32 Wins Cycles:55 45 | Dead Reason : Executed invalid instruction 46 | Dead Instruction: 0x00000390 invalid 47 | Combat Winner: old-flacucho.arm-32 48 | Combat initialized 5 amphibia.arm-32 vs x3ero0.x86-64 49 | Round-1 amphibia.arm-32 Wins Cycles:48 50 | Dead Reason : Executed invalid instruction out of ARENA 51 | Dead Instruction: 0xffffffffe92e0163 invalid 52 | Round-2 amphibia.arm-32 Wins Cycles:43 53 | Dead Reason : Executed invalid instruction 54 | Dead Instruction: 0x00000272 invalid 55 | Combat Winner: amphibia.arm-32 56 | Combat initialized 6 old-flacucho.arm-32 vs ricardoapl.x86-32 57 | Round-1 old-flacucho.arm-32 Wins Cycles:94 58 | Dead Reason : Instruction Read/Write out of ARENA. 59 | Dead Instruction: 0x00000189 jmp [0x2dffffa9] 60 | Round-2 old-flacucho.arm-32 Wins Cycles:113 61 | Dead Reason : Executed invalid instruction 62 | Dead Instruction: 0x00000128 invalid 63 | Combat Winner: old-flacucho.arm-32 64 | Tournament end 30/09/2021 21:11:53 65 | -------------------------------------------------------------------------------- /csharp/clsPipe.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | public interface IR2Pipe : System.IDisposable 3 | { 4 | /// 5 | /// Executes given RunCommand in radare2 6 | /// 7 | /// The command to execute. 8 | /// Returns a string 9 | string RunCommand(string command); 10 | } 11 | 12 | public class R2Pipe : IR2Pipe, System.IDisposable 13 | { 14 | /// 15 | /// Gets the radare2 path. 16 | /// 17 | /// 18 | /// The radare2 path. 19 | /// 20 | public string Radare2Path { get; private set; } 21 | 22 | [Obsolete("Please use RunCommandAsync() or the QueuedR2Pipe class")] 23 | public bool doAsync { get; set; } 24 | 25 | /// 26 | /// The r2 process 27 | /// 28 | internal System.Diagnostics.Process r2Process; 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The file. 34 | public R2Pipe() 35 | : this("-", "radare2") 36 | { 37 | } 38 | 39 | /// 40 | /// Initializes a new instance of the class. 41 | /// 42 | /// The file. 43 | public R2Pipe(string file) 44 | : this(file, "radare2") 45 | { 46 | } 47 | 48 | /// 49 | /// Initializes a new instance of the class. 50 | /// 51 | /// The file. 52 | /// The r2executable. 53 | public R2Pipe(string file, string r2executable) 54 | { 55 | if (file == null) 56 | file = "-"; 57 | 58 | r2Process = new System.Diagnostics.Process(); 59 | r2Process.StartInfo = new System.Diagnostics.ProcessStartInfo() 60 | { 61 | CreateNoWindow = true, 62 | RedirectStandardOutput = true, 63 | RedirectStandardInput = true, 64 | UseShellExecute = false, 65 | Arguments = "-q0 " + file, 66 | FileName = r2executable 67 | }; 68 | 69 | r2Process.Start(); 70 | r2Process.StandardInput.AutoFlush = true; 71 | r2Process.StandardInput.NewLine = "\n"; 72 | // ignore first run 73 | r2Process.StandardOutput.Read(); 74 | // Console.WriteLine(r2Process.StandardOutput.Read()); 75 | } 76 | 77 | /// 78 | /// Disposes this object. Exits r2 (if not already done) and disposes the process object too. 79 | /// 80 | public void Dispose() 81 | { 82 | if (!r2Process.HasExited) 83 | { 84 | this.RunCommand("q!"); 85 | r2Process.WaitForExit(); 86 | } 87 | r2Process.Dispose(); 88 | } 89 | 90 | /// 91 | /// Executes given RunCommand in radare2 92 | /// 93 | /// The command to execute. 94 | /// 95 | /// Returns a string 96 | /// 97 | public string RunCommand(string command) 98 | { 99 | var sb = new System.Text.StringBuilder(); 100 | r2Process.StandardInput.WriteLine(command); 101 | r2Process.StandardInput.Flush(); 102 | 103 | while (true) 104 | { 105 | char buffer = (char)r2Process.StandardOutput.Read(); 106 | 107 | if (buffer == 0x00) 108 | break; 109 | 110 | sb.Append(buffer); 111 | } 112 | return sb.ToString(); 113 | } 114 | 115 | } 116 | 117 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:labs 2 | ARG UBUNTU_RELEASE="22.04" 3 | ARG TIMEZONE="UTC" 4 | ARG R2_SOURCE="https://github.com/radareorg/radare2.git" 5 | ARG R2_INSTALL_DIR="/opt/r2" 6 | ARG CCACHE_DIR="/root/.cache/ccache" 7 | ARG CC="ccache gcc" 8 | ARG CXX="ccache g++" 9 | 10 | 11 | ################################################################################ 12 | # Base image for builder/runner # 13 | ################################################################################ 14 | FROM ubuntu:${UBUNTU_RELEASE} as base 15 | ARG TIMEZONE 16 | 17 | # Prepare timezone settings 18 | ENV TZ=${TIMEZONE} 19 | RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \ 20 | echo ${TIMEZONE} > /etc/timezone 21 | 22 | # Enable APT package caching 23 | RUN rm -f /etc/apt/apt.conf.d/docker-clean && \ 24 | echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache 25 | 26 | 27 | ################################################################################ 28 | # r2wars builder # 29 | ################################################################################ 30 | FROM base as r2wars-builder 31 | 32 | # Install base packages 33 | RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ 34 | --mount=type=cache,target=/var/lib/apt,sharing=locked \ 35 | apt-get update && \ 36 | apt-get install -y --no-install-recommends \ 37 | mono-complete 38 | 39 | # Add r2wars source and build it 40 | COPY --link csharp /r2wars 41 | 42 | WORKDIR /r2wars 43 | RUN xbuild /p:Configuration=Release r2wars.csproj 44 | 45 | 46 | ################################################################################ 47 | # r2 builder # 48 | ################################################################################ 49 | FROM base as r2-builder 50 | ARG CCACHE_DIR 51 | ARG CC 52 | ARG CXX 53 | ARG R2_SOURCE 54 | ARG R2_INSTALL_DIR 55 | 56 | # Install base packages 57 | RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ 58 | --mount=type=cache,target=/var/lib/apt,sharing=locked \ 59 | apt-get update && \ 60 | apt-get install -y --no-install-recommends \ 61 | build-essential \ 62 | ccache \ 63 | cmake \ 64 | meson \ 65 | ninja-build \ 66 | pkg-config \ 67 | git \ 68 | ca-certificates 69 | 70 | # By default, add r2 source from GitHub and build it -- replace the git repo 71 | # with your local path if you want to build your custom radare2 source tree 72 | ADD ${R2_SOURCE} /r2src 73 | 74 | WORKDIR /r2src 75 | 76 | RUN --mount=type=cache,id=ccache,target=${CCACHE_DIR},sharing=shared \ 77 | meson setup build \ 78 | -Dbuildtype=release \ 79 | -Dprefix=${R2_INSTALL_DIR} \ 80 | -Dlocal=true && \ 81 | ninja -C build install 82 | 83 | ################################################################################ 84 | # r2wars runner # 85 | ################################################################################ 86 | FROM base as runner 87 | ARG R2_INSTALL_DIR 88 | 89 | # Install base packages 90 | RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ 91 | --mount=type=cache,target=/var/lib/apt,sharing=locked \ 92 | apt-get update && \ 93 | apt-get install -y --no-install-recommends \ 94 | mono-runtime \ 95 | nuget 96 | 97 | # Copy r2 and r2wars in from the build stages 98 | COPY --from=r2wars-builder --link /r2wars/bin/Release /r2wars 99 | COPY --from=r2-builder --link ${R2_INSTALL_DIR} ${R2_INSTALL_DIR} 100 | ENV PATH=${PATH}:${R2_INSTALL_DIR}/bin 101 | 102 | EXPOSE 9664 9966 103 | 104 | WORKDIR /r2wars 105 | ENTRYPOINT ["mono", "r2wars.exe"] 106 | -------------------------------------------------------------------------------- /python/r2wars.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import re 4 | import curses 5 | import r2pipe 6 | import sys 7 | import time 8 | import random 9 | 10 | useCurses = True 11 | useArch = "x86" 12 | useBits = "32" 13 | 14 | ctr = 0 15 | uidx = 0 16 | user = [] 17 | name = [] 18 | wins = [] 19 | size = [] 20 | orig = [] 21 | stdscr = None 22 | 23 | memsize = 1024 24 | maxprogsize = 64 25 | r2 = r2pipe.open('malloc://%d'%(memsize)) 26 | #r2 = r2pipe.open('/bin/ls') 27 | r2.cmd("e asm.arch=%s"%(useArch)) 28 | r2.cmd("e asm.bits=%s"%(useBits)) 29 | r2.cmd("e scr.color=true") 30 | r2.cmd("aei") 31 | r2.cmd("aeim") 32 | 33 | def get_random_offsets(): 34 | while True: 35 | rand = [] 36 | addr = random.randint(0, memsize - maxprogsize) 37 | for a in sys.argv[1:]: 38 | rand.append(addr) 39 | addr = addr + random.randint(maxprogsize, maxprogsize + 300) 40 | if addr + maxprogsize > memsize: 41 | print "ERROR: Not enough memory" 42 | continue # sys.exit(1) 43 | random.shuffle(rand) 44 | break 45 | return rand 46 | 47 | def userScreen(c): 48 | global user, uidx, name, orig 49 | r2.cmd(user[uidx]) 50 | #print r2.cmd("?eg 0 0") 51 | #print r2.cmd("e hex.cols=32") 52 | #res = r2.cmd("pxa 200 @ 0") + "\n" 53 | res = '' 54 | res += "USER %s\n"%(name[uidx]) 55 | res += r2.cmd("aer") + "\n" 56 | res += r2.cmd("%s %d @ 0"%(c, memsize)) + "\n" 57 | res += r2.cmd("pxw 32 @r:SP") + "\n" 58 | res += r2.cmd("pD %d @ %s"%(size[uidx], orig[uidx])) 59 | #print("(((%s)))"%(user[uidx])) 60 | return res 61 | #print r2.cmd("e hex.cols=16") 62 | 63 | def stepIn(): 64 | global user, uidx 65 | #print r2.cmd("pi 1 @r:PC") 66 | r2.cmd("aes") 67 | user[uidx] = r2.cmd("aerR").replace("\n", ";") 68 | #print("USER %s ENDUSER"%(user[uidx])) 69 | 70 | def loadUserCode(): 71 | print "LOAD" 72 | 73 | def switchUser(): 74 | global user, uidx 75 | uidx = uidx + 1 76 | if uidx >= len(user): 77 | uidx = 0 78 | r2.cmd(user[uidx]) 79 | 80 | def shell(): 81 | while True: print(r2.cmd(raw_input())) 82 | 83 | def r2wars_plain(): 84 | global ctr, user, uidx 85 | ctr = 0 86 | while True: 87 | res = "\x1b[2J\x1b[0;0H" 88 | print(res + userScreen("prc")) 89 | stepIn() 90 | if checkDead(): 91 | who = removeUser() 92 | if who != None: 93 | print("\n\nThe winner is %s\n\n"%(who)) 94 | break 95 | switchUser() 96 | time.sleep(0.2) 97 | 98 | def checkDead(): 99 | global uidx, ctr 100 | te = r2.cmd("?v 1+theend").strip() 101 | ctr = ctr + 1 102 | #print "TE %s %s"%(uidx, te) 103 | if te != "" and te != "0x1": 104 | print ("USER %s DIED at %s"%(uidx, te)) 105 | return True 106 | return False 107 | 108 | def removeUser(): 109 | global user, uidx, ctr 110 | who = name[uidx] 111 | print("\n\rUSER %s HAS DIED"%(who)) 112 | sys.stdout.flush() 113 | time.sleep(2) 114 | del user[uidx] 115 | del name[uidx] 116 | del wins[uidx] 117 | del orig[uidx] 118 | del size[uidx] 119 | uidx = uidx - 1 120 | if uidx < 0 or uidx >= len(user): 121 | uidx = 0 122 | if len(user) < 2: 123 | return name[uidx] 124 | #shell() 125 | return None 126 | 127 | def r2wars_curses(): 128 | global stdscr, user, uidx 129 | r2.cmd("e scr.color=false") 130 | r2.cmd("e scr.utf8=false") 131 | stdscr = curses.initscr() 132 | #curses.start_color(); 133 | curses.noecho() 134 | (h, w) = stdscr.getmaxyx() 135 | 136 | x = 0 137 | for a in user: 138 | w2 = w / len(user) 139 | wins.append(curses.newwin(h, w2, 0, x)) 140 | x = x + w2 141 | who = "" 142 | while True: 143 | stdscr.refresh() 144 | (h, w) = stdscr.getmaxyx() 145 | uc = userScreen("prc") 146 | ansi_escape = re.compile(r'\x1b[^m]*m') 147 | uc = str(ansi_escape.sub('', uc)) 148 | uc = uc.replace("\r", "") 149 | n = 100 150 | ucs = uc.split("\n") 151 | 152 | a = wins[uidx] 153 | # relayout 154 | x = 0 155 | w2 = w / len(user) 156 | for w in wins: 157 | try: 158 | w.resize(1, 1) 159 | w.mvwin(0, x) 160 | w.resize(h, w2) 161 | except: 162 | pass 163 | x = x + w2 164 | a.clear() 165 | try: 166 | for u in ucs: 167 | a.addstr(str(u[:w2] + "\n")) 168 | except: 169 | pass 170 | a.refresh() 171 | stepIn() 172 | if checkDead(): 173 | who = removeUser() 174 | if who != None: 175 | break 176 | switchUser() 177 | stdscr.refresh() 178 | time.sleep(0.01) 179 | curses.endwin() 180 | if who: 181 | nextName = who + ".0" 182 | rs = "agn %s\n"%(who) 183 | rs += "agn %s\n"%(nextName) 184 | rs += "age %s %s\n"%(who, nextName) 185 | for x in sys.argv[1:]: 186 | rs += "agn %s\n"%(x) 187 | if x != who: 188 | rs += "age %s %s\n"%(who, x) 189 | print rs 190 | print("The Winner Is: %s"%(who)) 191 | 192 | 193 | if __name__ == '__main__': 194 | idx = 0 195 | offsets = get_random_offsets() 196 | for a in sys.argv[1:]: 197 | try: 198 | n = name.index(a) 199 | print(n) 200 | print("Cant have two players with the same script") 201 | sys.exit(1) 202 | except: 203 | pass 204 | addr = offsets[idx] 205 | idx = idx + 1 206 | src = r2.syscmd("rasm2 -f %s"%(a)).strip() 207 | if src == "": 208 | print("Invalid source") 209 | sys.exit(1) 210 | r2.cmd("wx %s @ %s"%(src, addr)) 211 | #print("wx %s @ %s"%(src, addr)) 212 | r2.cmd("aer PC=%s"%(addr)) 213 | r2.cmd("aer SP=SP+%s"%(addr)) 214 | initRegs = r2.cmd("aerR").replace("\n", ";") 215 | name.append(a) 216 | orig.append(addr) 217 | size.append(len(src) / 2) 218 | user.append(initRegs) 219 | if len(user) < 2: 220 | print("You need at least 2 users") 221 | sys.exit(1) 222 | r2.cmd("e cmd.esil.todo=f theend=1") 223 | r2.cmd("e cmd.esil.trap=f theend=1") 224 | r2.cmd("e cmd.esil.intr=f theend=1") 225 | r2.cmd("e cmd.esil.ioer=f theend=1") 226 | r2.cmd("f theend=0") 227 | 228 | print r2.cmd("b %d"%(memsize)) 229 | if useCurses: 230 | r2wars_curses() 231 | else: 232 | r2wars_plain() 233 | 234 | -------------------------------------------------------------------------------- /csharp/r2wars.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {7C07AB0A-D2B5-4546-B5B2-6DC6E77E40D1} 8 | Exe 9 | Properties 10 | r2warsTorneo 11 | r2wars 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | packages\Nancy.1.4.4\lib\net40\Nancy.dll 41 | True 42 | 43 | 44 | packages\Nancy.Hosting.Self.1.4.1\lib\net40\Nancy.Hosting.Self.dll 45 | True 46 | 47 | 48 | 49 | 50 | packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll 51 | True 52 | 53 | 54 | 55 | 56 | 57 | 58 | packages\WebSocketSharp.1.0.3-rc11\lib\websocket-sharp.dll 59 | True 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 | ResXFileCodeGenerator 85 | Resources.Designer.cs 86 | Designer 87 | 88 | 89 | True 90 | Resources.resx 91 | True 92 | 93 | 94 | 95 | SettingsSingleFileGenerator 96 | Settings.Designer.cs 97 | 98 | 99 | True 100 | Settings.settings 101 | True 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 118 | -------------------------------------------------------------------------------- /csharp/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 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 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | r2wars 2 | ====== 3 | 4 | r2wars is a game similar to [Core War](https://en.wikipedia.org/wiki/Core_War) (or pMARS) 5 | 6 | ![](show.jpg) 7 | 8 | [asciinema demo](https://asciinema.org/a/0zu3d2hlriuhdup8uel4znjtr) 9 | 10 | How it works 11 | ------------ 12 | 13 | Core War-style games are basically a competition between two programs to survive as much time as possible by sharing the memory space with other programs. 14 | 15 | In Core War or pmars, the code you run is from a specific artificial architecture, the differences with r2wars are the following: 16 | 17 | * Use any arch supported by ESIL 18 | * More than 2 programs can run at the same time 19 | * Cyclic execution cost matters for the turns 20 | 21 | Two or more programs written in assembly for MIPS, ARM, X86, are assembled with rasm2 and then emulated using ESIL. 22 | 23 | The program counter and stack pointers are initialized at random positions in a common shared memory address space for both programs. 24 | 25 | The r2wars scheduler will execute one instruction of each program on each turn, skipping some turns to adjust to the cyclic cost of execution of the specific instruction. 26 | 27 | The challenge 28 | ------------- 29 | 30 | The programs must find in memory the other program and overwrite it in order to make it crash. 31 | 32 | A crash happens when the program executes an invalid instruction or tries to read/write in a non-allocated address. Syscalls are ignored, but this may change after some discussion, as well as handling IO and catch unalignment memory accesses. 33 | 34 | The memory where those programs run is assumed to be `rwx`. 35 | 36 | Multiple techniques are used in order to achieve this: 37 | 38 | Your program can try to protect itself by replicating itself on different places and jump there, but you can also use offensive techniques like the one in this example code that aims to identify where the other's program live and nullify its bytes 39 | 40 | call label 41 | label: 42 | pop eax 43 | loop: 44 | sub eax, 10 45 | cmp [eax], 0 46 | je loop 47 | mov [eax], 0 48 | jmp loop 49 | 50 | Side benefits 51 | ------------- 52 | 53 | Despite of the main benefit of having fun competing with others just writing assembly code, r2wars aims to improve the support for more architectures, by supporting more instructions, better encodings, find and squash bugs in the assembler, enhance the emulation, identify problems in the ESIL emulation engine, etc.. 54 | 55 | 56 | References 57 | ---------- 58 | 59 | * http://www.koth.org/pmars/ 60 | 61 | Q&A 62 | === 63 | 64 | Where can I find some sample programs to take as a template? 65 | --- 66 | https://github.com/radareorg/radare2-extras/tree/master/r2wars/t 67 | 68 | How to make awesome warrior that wins r2wars if I'm a n00b? 69 | --- 70 | There are several techniques that may allow your program to survive for more time. Bear in mind that there's no perfect code to win because that will depend on the other player. 71 | 72 | I'm writing a program and seems like is not assembling one instruction properly 73 | --- 74 | r2wars uses rasm2 under the hood to generate binary code. You may use this program to check if the generated code is correct or not. 75 | 76 | Alignment 77 | --- 78 | ARM and MIPS have memory alignment restrictions, so you dont want to run code or access unaligned addresses. 79 | 80 | This is pending to be implemented, but will be done before r2con. See those bugs for more details 81 | 82 | https://github.com/radareorg/radare2/labels/r2wars 83 | 84 | How is this code executed? 85 | --- 86 | r2 emulates code using ESIL, it's executed in a turn-based model, Each turn, the r2wars engine will compute the cicles needed to execute the next instruction and will decrement that counter by one and execute it when ready. 87 | 88 | This is, instructions accessing memory are slower than the ones just messing with registers. 89 | 90 | Which architectures will be used in the competition? 91 | --- 92 | x86, mips, arm 93 | 94 | That's cool, but which specific models of cpu? 95 | --- 96 | - x86: -a x86 -b 32 97 | - mips: -a mips -b 32 98 | - arm: -a arm -b 64 99 | 100 | I think arm64 is better than arm32/16 for the competition, but thumb/arm switches could be really tricky. 101 | 102 | Will x86 programs compete against mips or arm ones? 103 | --- 104 | No, despite being possible, because ESIL abstracts the execution of machine code. But in this tournament we will only make x86 programs fight against other x86 programs, and the same goes for arm and mips. 105 | 106 | Maybe this can be an interesting option for next year. But not this time. 107 | 108 | As a n00b should I focus on one arch? 109 | --- 110 | The aim of this competition is to learn more about those archs, enhance the support for them in assembler and emulation and fun. Pun on this last point. so, having even a basic program for all arches would make the competition more fun. usually x86 is the most common entrypoint for assembler writers. 111 | 112 | How big is the memory? 113 | --- 114 | For now, we will use 1KB, allocated at address 0. Reading or writing beyond those limits will make your program crash 115 | 116 | How big can my program be? 117 | --- 118 | Both programs should fit in this memory, so, the bigger your program is, the easier to find by the other player. 119 | 120 | Stack and Code share the same address space? 121 | --- 122 | No. Stack is shared btw both program but dont is stored at same address space as code. 123 | 124 | But you can use stack-related instructions to peek/poke memory too and try to overwrite enemy stack ... 125 | 126 | At this moment im thinking to increment the memory space and share with stack. 127 | 128 | Warriors Types and how to design it 129 | --- 130 | You dont need have a big notions of asm to made ur own warrior, take in mind the objetives: 131 | - locate and destroy the enemy 132 | - survive and wait a enemy error 133 | - both of them 134 | 135 | To acomplish this objetives u only need know a fews instructions, especially those related to memory movements. 136 | 137 | 138 | Which kind of programs can we do? 139 | --- 140 | - rabbit 141 | - imp 142 | - bomber 143 | - vampire 144 | - replicator 145 | 146 | http://www.pbm.com/~lindahl/pbem_articles/corewars 147 | 148 | How to get the current program counter? 149 | --- 150 | The first thing most programs will do is to locate themselves in memory, but this is not a mandatory requirement. 151 | - x86: call me;me:;pop eax 152 | - arm64: bl, adrp.. but its a pain 153 | - mips: blx and then mov t0, ra 154 | - arm32: pc is r15 and can be accessed like any other reg 155 | 156 | How to debug ur warriors 157 | == 158 | 159 | Assemble ur bot: 160 | --------------- 161 | 1) Use rasm2 to encode ur warrior: 162 | - mips: rasm2 -a mips -b 32 -f warrior.asm 163 | - arm : rasm2 -a arm -b 64 -f warrior.asm 164 | - x86 : rasm2 -a x86 -b 32 -f warrior.asm 165 | 166 | 2) Copy the output to use into radare2. 167 | 168 | Load into radare2: 169 | ------------------ 170 | 1) radare2 malloc://1024 171 | 2) select ur arch: e asm.arch = mips|arm|x86 172 | 3) select ur bits: e asm.bits = 8|16|32|64 173 | 4) type theses commands: 174 | - aei 175 | - aeim 176 | - wx "paste output from rasm2" @ 100 177 | - aer PC=100 178 | - aer SP=SP+100 179 | 5) now u can use visual mode or "aes" to debug ur warrior. 180 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/현수 차/soo.x86-32.asm: -------------------------------------------------------------------------------- 1 | jmp real_start 2 | 3 | ### dummy 4 | .hex 0x9D 5 | .hex 0x77 6 | .hex 0xC6 7 | .hex 0x08 8 | .hex 0x6E 9 | .hex 0x4A 10 | .hex 0x69 11 | .hex 0xD5 12 | .hex 0xEA 13 | .hex 0xFC 14 | .hex 0xEA 15 | .hex 0xAE 16 | .hex 0xE6 17 | .hex 0x24 18 | .hex 0x14 19 | .hex 0x84 20 | .hex 0xB7 21 | .hex 0x1C 22 | .hex 0xD6 23 | .hex 0xB8 24 | .hex 0x87 25 | .hex 0xD4 26 | .hex 0x65 27 | .hex 0x71 28 | .hex 0x7B 29 | .hex 0xD9 30 | .hex 0x2E 31 | .hex 0x12 32 | .hex 0x84 33 | .hex 0x78 34 | .hex 0x8E 35 | .hex 0x73 36 | .hex 0xD2 37 | .hex 0x48 38 | .hex 0x6E 39 | .hex 0xAD 40 | .hex 0x49 41 | .hex 0x93 42 | .hex 0x3B 43 | .hex 0x98 44 | .hex 0x74 45 | .hex 0x56 46 | .hex 0xE1 47 | .hex 0x62 48 | .hex 0xD3 49 | .hex 0xDC 50 | .hex 0xB4 51 | .hex 0xC9 52 | .hex 0x7A 53 | .hex 0x25 54 | .hex 0x71 55 | .hex 0xE3 56 | .hex 0x63 57 | .hex 0xA3 58 | .hex 0xCE 59 | .hex 0x86 60 | .hex 0xF3 61 | .hex 0xF8 62 | .hex 0x38 63 | .hex 0xB5 64 | .hex 0x7A 65 | .hex 0xC5 66 | .hex 0xAF 67 | .hex 0xA7 68 | .hex 0xCA 69 | .hex 0xB0 70 | .hex 0xF1 71 | .hex 0x44 72 | .hex 0x23 73 | .hex 0x30 74 | .hex 0x5C 75 | .hex 0x3B 76 | .hex 0xFF 77 | .hex 0xD3 78 | .hex 0x2F 79 | .hex 0x03 80 | .hex 0x97 81 | .hex 0xF5 82 | .hex 0x1D 83 | .hex 0x6C 84 | .hex 0x23 85 | .hex 0x2D 86 | .hex 0x62 87 | .hex 0x97 88 | .hex 0x23 89 | .hex 0xEB 90 | .hex 0xAF 91 | .hex 0x74 92 | .hex 0x3A 93 | .hex 0xF8 94 | .hex 0xB9 95 | .hex 0x1B 96 | .hex 0x6D 97 | .hex 0xE5 98 | .hex 0x40 99 | .hex 0xA9 100 | .hex 0xD4 101 | .hex 0x97 102 | .hex 0xC4 103 | .hex 0x6D 104 | .hex 0xFB 105 | .hex 0x74 106 | .hex 0x4A 107 | .hex 0x92 108 | .hex 0x8D 109 | .hex 0xE6 110 | .hex 0xF1 111 | .hex 0x90 112 | .hex 0x14 113 | .hex 0x3B 114 | .hex 0x2C 115 | .hex 0x10 116 | .hex 0xCD 117 | .hex 0x10 118 | .hex 0xD7 119 | .hex 0x16 120 | .hex 0xEF 121 | .hex 0xD0 122 | .hex 0x9E 123 | .hex 0x92 124 | .hex 0xDE 125 | .hex 0xFC 126 | .hex 0x4B 127 | .hex 0xA7 128 | .hex 0x2A 129 | .hex 0x35 130 | .hex 0xF7 131 | .hex 0x61 132 | .hex 0x52 133 | .hex 0x4D 134 | .hex 0x4C 135 | .hex 0x8C 136 | .hex 0xA1 137 | .hex 0xD6 138 | .hex 0x37 139 | .hex 0xF5 140 | .hex 0xB8 141 | .hex 0xE7 142 | .hex 0xBE 143 | .hex 0x4D 144 | .hex 0x82 145 | .hex 0x1E 146 | .hex 0xED 147 | .hex 0x5E 148 | .hex 0xA5 149 | .hex 0x0D 150 | .hex 0xF1 151 | .hex 0x66 152 | .hex 0xC1 153 | .hex 0x9D 154 | .hex 0xE9 155 | .hex 0xB9 156 | .hex 0x02 157 | .hex 0x10 158 | .hex 0xFC 159 | .hex 0x00 160 | .hex 0xD3 161 | .hex 0xB8 162 | .hex 0xBB 163 | .hex 0xB9 164 | .hex 0xBB 165 | .hex 0x84 166 | .hex 0xE5 167 | .hex 0xC7 168 | .hex 0xBB 169 | .hex 0xF0 170 | .hex 0x07 171 | .hex 0x40 172 | .hex 0xAB 173 | .hex 0x10 174 | .hex 0x9D 175 | .hex 0xC4 176 | .hex 0x6A 177 | .hex 0xB1 178 | .hex 0xA4 179 | .hex 0x04 180 | .hex 0xEA 181 | .hex 0xCA 182 | .hex 0xC6 183 | .hex 0x4F 184 | .hex 0x69 185 | .hex 0xBC 186 | .hex 0x8E 187 | .hex 0x47 188 | .hex 0x5C 189 | .hex 0x1F 190 | .hex 0x4F 191 | .hex 0x10 192 | .hex 0xDA 193 | .hex 0x13 194 | .hex 0xAA 195 | .hex 0xA1 196 | .hex 0x99 197 | .hex 0x51 198 | .hex 0xDF 199 | .hex 0x0B 200 | .hex 0xC2 201 | .hex 0x81 202 | .hex 0x56 203 | .hex 0xD3 204 | .hex 0x26 205 | .hex 0x82 206 | .hex 0x0A 207 | .hex 0xC0 208 | .hex 0xAA 209 | .hex 0xAE 210 | .hex 0xC7 211 | .hex 0xB2 212 | .hex 0xF2 213 | .hex 0x4E 214 | .hex 0x5D 215 | .hex 0x60 216 | .hex 0x8A 217 | .hex 0xBF 218 | .hex 0x41 219 | .hex 0x1F 220 | .hex 0x34 221 | .hex 0xFB 222 | .hex 0x3A 223 | .hex 0x05 224 | .hex 0x08 225 | .hex 0x8F 226 | .hex 0x14 227 | .hex 0x0B 228 | .hex 0x8D 229 | .hex 0x2F 230 | .hex 0x7C 231 | .hex 0x06 232 | .hex 0x04 233 | .hex 0x6C 234 | .hex 0x6F 235 | .hex 0x92 236 | .hex 0x7C 237 | .hex 0x3E 238 | .hex 0xF5 239 | .hex 0x53 240 | .hex 0x76 241 | .hex 0x6E 242 | .hex 0x01 243 | .hex 0x1E 244 | .hex 0x26 245 | .hex 0x06 246 | .hex 0xB5 247 | .hex 0xEA 248 | .hex 0x9D 249 | .hex 0x5B 250 | .hex 0x6A 251 | .hex 0xA7 252 | .hex 0x6A 253 | .hex 0x5A 254 | .hex 0x27 255 | .hex 0x52 256 | .hex 0x7A 257 | .hex 0x1B 258 | .hex 0x7E 259 | .hex 0xEF 260 | .hex 0x48 261 | .hex 0xFD 262 | .hex 0xF3 263 | .hex 0x2C 264 | .hex 0xA1 265 | .hex 0xB7 266 | .hex 0x56 267 | .hex 0xE4 268 | .hex 0x95 269 | .hex 0x2D 270 | .hex 0xC2 271 | .hex 0xD0 272 | .hex 0x52 273 | .hex 0xF2 274 | .hex 0x30 275 | .hex 0x01 276 | .hex 0x02 277 | .hex 0xC2 278 | .hex 0xBF 279 | .hex 0x03 280 | .hex 0xEB 281 | .hex 0x69 282 | .hex 0x24 283 | .hex 0xC7 284 | .hex 0x6E 285 | .hex 0xD4 286 | .hex 0xF3 287 | .hex 0xAE 288 | .hex 0xA0 289 | .hex 0x48 290 | .hex 0xA0 291 | .hex 0x47 292 | .hex 0x92 293 | .hex 0xFB 294 | .hex 0x70 295 | .hex 0xB4 296 | .hex 0x90 297 | .hex 0x8E 298 | .hex 0xBF 299 | .hex 0xB6 300 | .hex 0xEE 301 | .hex 0x1A 302 | .hex 0x4A 303 | .hex 0xD0 304 | .hex 0x1B 305 | .hex 0xDE 306 | .hex 0x68 307 | .hex 0x17 308 | .hex 0x17 309 | .hex 0xB6 310 | .hex 0x5F 311 | .hex 0x83 312 | .hex 0x94 313 | .hex 0xE4 314 | .hex 0x3F 315 | .hex 0xEF 316 | .hex 0x47 317 | .hex 0xE7 318 | .hex 0xF1 319 | .hex 0x12 320 | .hex 0x3F 321 | .hex 0x4C 322 | .hex 0x67 323 | .hex 0x13 324 | .hex 0x44 325 | .hex 0xD2 326 | .hex 0x11 327 | .hex 0x9B 328 | .hex 0x99 329 | .hex 0x3E 330 | .hex 0x14 331 | .hex 0x78 332 | .hex 0x96 333 | .hex 0xB3 334 | .hex 0xD8 335 | .hex 0x30 336 | .hex 0xFD 337 | .hex 0x78 338 | .hex 0xEE 339 | .hex 0x21 340 | .hex 0x0B 341 | .hex 0x7A 342 | .hex 0x6E 343 | .hex 0x08 344 | .hex 0x8D 345 | .hex 0xEF 346 | .hex 0x3E 347 | .hex 0x10 348 | .hex 0x8F 349 | .hex 0xF4 350 | .hex 0xE7 351 | .hex 0xBE 352 | .hex 0x6E 353 | .hex 0x01 354 | .hex 0xF3 355 | .hex 0x55 356 | .hex 0x4F 357 | .hex 0x8B 358 | .hex 0xEA 359 | .hex 0xA0 360 | .hex 0x5A 361 | .hex 0x3C 362 | .hex 0x73 363 | .hex 0x1E 364 | .hex 0x31 365 | .hex 0x8D 366 | .hex 0x2D 367 | .hex 0x10 368 | .hex 0x7C 369 | .hex 0xAE 370 | .hex 0x3D 371 | .hex 0xE4 372 | .hex 0x96 373 | .hex 0x0A 374 | .hex 0xBA 375 | .hex 0xF4 376 | .hex 0x9B 377 | .hex 0xCD 378 | .hex 0x59 379 | .hex 0xA1 380 | .hex 0x73 381 | .hex 0x40 382 | .hex 0x0F 383 | .hex 0x33 384 | .hex 0x9A 385 | .hex 0xE4 386 | .hex 0x99 387 | .hex 0x14 388 | .hex 0xB5 389 | .hex 0x93 390 | .hex 0x02 391 | .hex 0x45 392 | .hex 0x45 393 | .hex 0x1C 394 | .hex 0xAD 395 | .hex 0x20 396 | .hex 0xF7 397 | .hex 0x1D 398 | .hex 0x7C 399 | .hex 0xD4 400 | .hex 0x6E 401 | .hex 0x0F 402 | .hex 0x04 403 | .hex 0x2A 404 | .hex 0x85 405 | .hex 0xC7 406 | .hex 0x04 407 | .hex 0x6D 408 | .hex 0x5B 409 | .hex 0xE7 410 | .hex 0x7C 411 | .hex 0x9A 412 | .hex 0xB5 413 | .hex 0xF4 414 | .hex 0x18 415 | .hex 0x38 416 | .hex 0x83 417 | .hex 0x17 418 | .hex 0xE2 419 | .hex 0x5C 420 | .hex 0x8D 421 | .hex 0xBE 422 | .hex 0x54 423 | .hex 0xD3 424 | .hex 0x9E 425 | .hex 0x9B 426 | .hex 0x49 427 | .hex 0x79 428 | .hex 0xB3 429 | .hex 0xC1 430 | .hex 0x6E 431 | .hex 0x26 432 | .hex 0xFC 433 | .hex 0xCE 434 | .hex 0x26 435 | .hex 0xC0 436 | .hex 0xB8 437 | .hex 0x75 438 | .hex 0x01 439 | .hex 0x5B 440 | .hex 0x3B 441 | .hex 0xCA 442 | .hex 0x45 443 | .hex 0x7B 444 | .hex 0xAC 445 | .hex 0x1E 446 | .hex 0x23 447 | .hex 0xD8 448 | .hex 0x3E 449 | .hex 0x60 450 | .hex 0x8A 451 | .hex 0x3B 452 | .hex 0x01 453 | .hex 0x41 454 | .hex 0xCE 455 | .hex 0x54 456 | .hex 0x7E 457 | .hex 0x97 458 | .hex 0x7E 459 | .hex 0xAA 460 | .hex 0xC6 461 | .hex 0xB6 462 | .hex 0x1F 463 | 464 | real_start: 465 | cpuid 466 | 467 | mov esp, 512 468 | pushad 469 | pushad 470 | pushad 471 | pushad 472 | pushad 473 | pushad 474 | pushad 475 | pushad 476 | pushad 477 | pushad 478 | pushad 479 | pushad 480 | pushad 481 | pushad 482 | pushad 483 | pushad 484 | 485 | mov esp, 1015 486 | 487 | mov esi, 1016 488 | mov [esi], 0x60606060 489 | mov [esi+4], 0xe6ff6060 490 | 491 | jmp esi -------------------------------------------------------------------------------- /vlang/r2wars/lib.v: -------------------------------------------------------------------------------- 1 | module r2wars 2 | 3 | import os 4 | import term 5 | import time 6 | import rand 7 | import radare.r2pipe 8 | 9 | pub const ( 10 | arenasize = 512 11 | maxcycles = 200 12 | version = '0.1.0' 13 | ) 14 | 15 | pub struct Bot { 16 | name string 17 | file string 18 | arch string 19 | bits int 20 | size int 21 | battles int 22 | code string 23 | data string // # assembled 24 | mut: 25 | r2 r2pipe.R2Pipe 26 | cycles int 27 | regs string 28 | dead bool 29 | wins int 30 | lost int 31 | steps int 32 | index int 33 | } 34 | 35 | pub struct BattleResult { 36 | winner &Bot 37 | loser &Bot 38 | timeout bool 39 | cycles int 40 | } 41 | 42 | pub struct War { 43 | pub mut: 44 | bots []Bot 45 | verbose bool 46 | // r := r2pipe.new() 47 | } 48 | 49 | fn rasm2_flags(file string) ?(string, int) { 50 | if file.contains('.8051.asm') { 51 | return '8051', 8 52 | } 53 | if file.contains('.8051-8.asm') { 54 | return '8051', 8 55 | } 56 | if file.contains('.x86-16.asm') { 57 | return 'x86', 16 58 | } 59 | if file.contains('.x86-32.asm') { 60 | return 'x86', 32 61 | } 62 | if file.contains('.x86-64.asm') { 63 | return 'x86', 64 64 | } 65 | if file.contains('.arm-64.asm') { 66 | return 'arm', 64 67 | } 68 | if file.contains('.arm-32.asm') { 69 | return 'arm', 32 70 | } 71 | if file.contains('.arm-16.asm') { 72 | return 'arm', 16 73 | } 74 | if file.contains('.mips-32.asm') { 75 | return 'mips', 32 76 | } 77 | if file.contains('.mips-64.asm') { 78 | return 'mips', 64 79 | } 80 | return error('unkwnown arch. $file') 81 | } 82 | 83 | fn rasm2(file string, flags string) ?string { 84 | line := 'rasm2 $flags -f $file' 85 | r := os.exec(line) or { 86 | return err 87 | } 88 | return r.output 89 | } 90 | 91 | pub fn new_bot(file string) ?Bot { 92 | i := file.last_index('/') or { 93 | return error('Invalid path') 94 | } 95 | bot_name := file[(i+1)..].replace('.asm', '') 96 | bot_code := os.read_file(file) or { 97 | return error('Cannot open file') 98 | } 99 | arch, bits := rasm2_flags(file) or { 100 | return error(err) 101 | } 102 | flags := '-a $arch -b $bits' 103 | bot_data := rasm2(file, flags) or { 104 | return error('Cannot open file') 105 | } 106 | bot := Bot{ 107 | name: bot_name 108 | file: file 109 | arch: arch 110 | bits: bits 111 | wins: 0 112 | lost: 0 113 | battles: 0 114 | code: bot_code 115 | data: bot_data 116 | size: bot_data.len / 2 117 | dead: false 118 | } 119 | return bot 120 | } 121 | 122 | pub fn new() &War { 123 | return &War{} 124 | } 125 | 126 | fn (mut war War)fight_vs(mut bot0 Bot, mut bot1 Bot) ?BattleResult { 127 | bot0.r2 = r2pipe.spawn('malloc://$arenasize', 'r2 -w -n -NN -q0 -a ${bot0.arch} -b ${bot0.bits}') or { 128 | panic(err) 129 | } 130 | 131 | bot1.r2 = r2pipe.spawn('malloc://$arenasize', 'r2 -w -n -NN -q0 -a ${bot1.arch} -b ${bot1.bits}') or { 132 | panic(err) 133 | } 134 | // eprintln(bot0.r2.cmd('pd 10')) 135 | 136 | res := war.battle(mut bot0, mut bot1) or { 137 | panic(err) 138 | } 139 | bot0.r2.free() 140 | bot1.r2.free() 141 | return res 142 | } 143 | 144 | pub fn (mut war War)fight() ? { 145 | if war.bots.len < 2 { 146 | return error('not enough bots') 147 | } 148 | 149 | for mut bot in war.bots { 150 | for mut but in war.bots { 151 | if bot.index != but.index { 152 | for _ in 0 .. 3 { 153 | res := war.fight_vs(mut bot, mut but) or { 154 | panic(err) 155 | } 156 | eprintln('$res') 157 | } 158 | } 159 | } 160 | } 161 | 162 | println('wins\tlost\twi/lo\tsteps\tname') 163 | for bot in war.bots { 164 | lost := if bot.lost > 0 { bot.lost } else { 1 } 165 | p := f64(bot.wins) / lost 166 | println('${bot.wins}\t${bot.lost}\t$p\t${bot.steps}\t- ${bot.name} ') 167 | } 168 | 169 | } 170 | 171 | fn randposes(mut bot0 Bot, mut bot1 Bot) ?(int, int) { 172 | mut pos0 := 0 173 | mut pos1 := 0 174 | mut tries := 10 175 | for true { 176 | tries-- 177 | if tries == 0 { 178 | return error('cannot fit') 179 | } 180 | pos0 = rand.intn(arenasize-bot0.size) 181 | pos1 = rand.intn(arenasize-bot1.size) 182 | pos0 -= pos0 % 4 183 | pos1 -= pos1 % 4 184 | if pos0 < pos1 { 185 | if pos0 + bot0.size >= pos1 { 186 | continue 187 | } 188 | } else if pos1 < pos0 { 189 | if pos1 + bot1.size >= pos0 { 190 | continue 191 | } 192 | } 193 | break 194 | } 195 | return pos0, pos1 196 | } 197 | 198 | fn setup(mut bot Bot, pc int, sp int) { 199 | bot.r2.cmd('e asm.bytes=true') 200 | bot.r2.cmd('e asm.flags=false') 201 | bot.r2.cmd('e cfg.r2wars=true') 202 | bot.r2.cmd('e hex.compact=true') 203 | bot.r2.cmd('e hex.cols=32') 204 | bot.r2.cmd('e scr.color=2') 205 | bot.r2.cmd('wx ${bot.data} @ pc') 206 | bot.r2.cmd('ar PC=$pc') 207 | bot.r2.cmd('ar SP=$sp') 208 | bot.dead = false 209 | bot.regs = bot.r2.cmd('ar*') 210 | } 211 | 212 | pub fn (mut war War)battle(mut bot0 Bot, mut bot1 Bot) ?BattleResult { 213 | pos0, pos1 := randposes(mut bot0, mut bot1) or { 214 | return error(err) 215 | } 216 | if war.verbose { 217 | eprintln('Positions: $pos0, $pos1') 218 | } 219 | 220 | mut bot := if rand.intn(2) == 1 { bot0 } else { bot1 } 221 | 222 | sp := arenasize / 2 223 | setup(mut bot0, pos0, sp) 224 | setup(mut bot1, pos1, sp) 225 | if war.verbose { 226 | term.clear() 227 | } 228 | mut cycles := 0 229 | for true { 230 | cycles++ 231 | if cycles > maxcycles { 232 | eprintln('TIMEOUT') 233 | bot0.dead = true 234 | bot1.dead = true 235 | time.sleep(1) 236 | break 237 | } 238 | y := if bot == bot0 { 0 } else { 13 } 239 | have_cycles := bot.cycles > 0 240 | mut data := '' 241 | if have_cycles { 242 | if war.verbose { 243 | term.set_cursor_position({x:0,y:y}) 244 | println('[$cycles] cc=${bot.cycles} wins=${bot.wins} lost=${bot.lost} steps=${bot.steps} ${bot.name}') 245 | } 246 | bot.cycles-- 247 | if bot.cycles == 0 { 248 | /* 249 | for reg in bot.regs.split('\n') { 250 | bot.r2.cmd(reg) 251 | } 252 | */ 253 | bot.r2.cmd('aes') 254 | war.bots[bot.index].steps++ 255 | bot.steps++ 256 | bot.r2.cmd('.ar*') 257 | // pc := bot.r2.cmd('ar PC').int() 258 | pcmap := bot.r2.cmd('om.@r:PC') 259 | // eprintln('PCMAAP(${pcmap.len},$pcmap,${pcmap[0]})') 260 | if pcmap == '' { 261 | bot.dead = true 262 | } 263 | data = bot.r2.cmd('p8 $arenasize @ 0') 264 | // bot.regs = bot.r2.cmd('ar*') 265 | } 266 | } else { 267 | // bot.regs = bot.r2.cmd('ar*') 268 | // bot.r2.cmd(bot.regs) 269 | mut cc := bot.r2.cmd('ao@r:PC~cycles[1]').trim_right('\r\n') 270 | if '$cc' == '' { 271 | bot.dead = true 272 | } 273 | tt := bot.r2.cmd('ao@r:PC~^type[1]').trim_right('\r\n') 274 | if tt == 'ill' { 275 | bot.dead = true 276 | } 277 | if cc.int() == 0 { 278 | // eprintln ('This arch doesnt does cycles properly') 279 | cc = '1' // bot.dead = true 280 | } 281 | if war.verbose { 282 | term.set_cursor_position({x:0,y:y}) 283 | println('$bot.cycles') 284 | term.set_cursor_position({x:0,y:y + 2}) 285 | r := bot.r2.cmd('pd 1@r:PC') 286 | s := bot.r2.cmd('ar=@e:hex.cols=16') 287 | println('$r\n$s') 288 | } 289 | bot.cycles = cc.int() 290 | // read memory 291 | } 292 | if war.verbose { 293 | term.set_cursor_position({x:0,y:26}) 294 | println('${bot.name}') 295 | println(bot.r2.cmd('pxa $arenasize @ 0')) 296 | } 297 | 298 | if bot.dead { 299 | war.bots[bot.index].lost++ 300 | if war.verbose { 301 | r := bot.r2.cmd('pd 1@r:PC') 302 | eprintln('IS DEAAAD ${bot.name}\n$r') 303 | } 304 | mut winner := if bot == bot0 { bot1 } else { bot0 } 305 | war.bots[winner.index].wins++ 306 | if war.verbose { 307 | r := winner.r2.cmd('pd 1@r:PC') 308 | eprintln('WINNER IS ${winner.name} ${winner.wins}/${winner.lost}\n$r') 309 | time.sleep(1) 310 | } else { 311 | eprintln('WIN ${winner.name}') 312 | eprintln('LOS ${bot.name}') 313 | } 314 | break 315 | } 316 | bot = if bot == bot0 { bot1 } else { bot0 } 317 | if data != '' { 318 | bot.r2.cmd('wx $data @ 0') 319 | } 320 | } 321 | return BattleResult { 322 | winner: if bot0.dead { bot1 } else { bot0 } 323 | loser: if bot0.dead { bot0 } else { bot1 } 324 | timeout: bot0.dead && bot1.dead 325 | cycles: cycles 326 | } 327 | // return error('everything exploded') 328 | } 329 | 330 | pub fn (mut war War)load_bots(dir string) ? { 331 | files := os.ls(dir) or { 332 | return error(err) 333 | } 334 | for file in files { 335 | eprintln('- $file') 336 | mut bot := new_bot('$dir/$file') or { 337 | return error(err) 338 | } 339 | bot.index = war.bots.len 340 | war.bots << bot 341 | } 342 | } 343 | 344 | pub fn (war &War)free() { 345 | } 346 | -------------------------------------------------------------------------------- /examples/r2con2020/round1/goyo/gordasco.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; Warrior X86 32 bits by goyo. 2 | ; Despues del RevientaViejas (r2con2018), viene: 'GORDASCO' 3 | ; bot para r2wars (r2con2020) 4 | ; Básicamente un replicator con problemas de peso 5 | 6 | .bits 32 7 | Main: 8 | CALL Boot 9 | Boot: 10 | POP ESI 11 | JMP replicator 12 | # Esto para engordar el binario a 512 bytes y reducir el area de busqueda inicial del otro bot a 512. 13 | # Si es rápido podría encontrar al otro antes de que se mueva si es que se mueve. 14 | 15 | .byte 0xff 16 | .byte 0xff 17 | .byte 0xff 18 | .byte 0xff 19 | .byte 0xff 20 | .byte 0xff 21 | .byte 0xff 22 | .byte 0xff 23 | .byte 0xff 24 | .byte 0xff 25 | .byte 0xff 26 | .byte 0xff 27 | .byte 0xff 28 | .byte 0xff 29 | .byte 0xff 30 | .byte 0xff 31 | .byte 0xff 32 | .byte 0xff 33 | .byte 0xff 34 | .byte 0xff 35 | .byte 0xff 36 | .byte 0xff 37 | .byte 0xff 38 | .byte 0xff 39 | .byte 0xff 40 | .byte 0xff 41 | .byte 0xff 42 | .byte 0xff 43 | .byte 0xff 44 | .byte 0xff 45 | .byte 0xff 46 | .byte 0xff 47 | .byte 0xff 48 | .byte 0xff 49 | .byte 0xff 50 | .byte 0xff 51 | .byte 0xff 52 | .byte 0xff 53 | .byte 0xff 54 | .byte 0xff 55 | .byte 0xff 56 | .byte 0xff 57 | .byte 0xff 58 | .byte 0xff 59 | .byte 0xff 60 | .byte 0xff 61 | .byte 0xff 62 | .byte 0xff 63 | .byte 0xff 64 | .byte 0xff 65 | .byte 0xff 66 | .byte 0xff 67 | .byte 0xff 68 | .byte 0xff 69 | .byte 0xff 70 | .byte 0xff 71 | .byte 0xff 72 | .byte 0xff 73 | .byte 0xff 74 | .byte 0xff 75 | .byte 0xff 76 | .byte 0xff 77 | .byte 0xff 78 | .byte 0xff 79 | .byte 0xff 80 | .byte 0xff 81 | .byte 0xff 82 | .byte 0xff 83 | .byte 0xff 84 | .byte 0xff 85 | .byte 0xff 86 | .byte 0xff 87 | .byte 0xff 88 | .byte 0xff 89 | .byte 0xff 90 | .byte 0xff 91 | .byte 0xff 92 | .byte 0xff 93 | .byte 0xff 94 | .byte 0xff 95 | .byte 0xff 96 | .byte 0xff 97 | .byte 0xff 98 | .byte 0xff 99 | .byte 0xff 100 | .byte 0xff 101 | .byte 0xff 102 | .byte 0xff 103 | .byte 0xff 104 | .byte 0xff 105 | .byte 0xff 106 | .byte 0xff 107 | .byte 0xff 108 | .byte 0xff 109 | .byte 0xff 110 | .byte 0xff 111 | .byte 0xff 112 | .byte 0xff 113 | .byte 0xff 114 | .byte 0xff 115 | .byte 0xff 116 | .byte 0xff 117 | .byte 0xff 118 | .byte 0xff 119 | .byte 0xff 120 | .byte 0xff 121 | .byte 0xff 122 | .byte 0xff 123 | .byte 0xff 124 | .byte 0xff 125 | .byte 0xff 126 | .byte 0xff 127 | .byte 0xff 128 | .byte 0xff 129 | .byte 0xff 130 | .byte 0xff 131 | .byte 0xff 132 | .byte 0xff 133 | .byte 0xff 134 | .byte 0xff 135 | .byte 0xff 136 | .byte 0xff 137 | .byte 0xff 138 | .byte 0xff 139 | .byte 0xff 140 | .byte 0xff 141 | .byte 0xff 142 | .byte 0xff 143 | .byte 0xff 144 | .byte 0xff 145 | .byte 0xff 146 | .byte 0xff 147 | .byte 0xff 148 | .byte 0xff 149 | .byte 0xff 150 | .byte 0xff 151 | .byte 0xff 152 | .byte 0xff 153 | .byte 0xff 154 | .byte 0xff 155 | .byte 0xff 156 | .byte 0xff 157 | .byte 0xff 158 | .byte 0xff 159 | .byte 0xff 160 | .byte 0xff 161 | .byte 0xff 162 | .byte 0xff 163 | .byte 0xff 164 | .byte 0xff 165 | .byte 0xff 166 | .byte 0xff 167 | .byte 0xff 168 | .byte 0xff 169 | .byte 0xff 170 | .byte 0xff 171 | .byte 0xff 172 | .byte 0xff 173 | .byte 0xff 174 | .byte 0xff 175 | .byte 0xff 176 | .byte 0xff 177 | .byte 0xff 178 | .byte 0xff 179 | .byte 0xff 180 | .byte 0xff 181 | .byte 0xff 182 | .byte 0xff 183 | .byte 0xff 184 | .byte 0xff 185 | .byte 0xff 186 | .byte 0xff 187 | .byte 0xff 188 | .byte 0xff 189 | .byte 0xff 190 | .byte 0xff 191 | .byte 0xff 192 | .byte 0xff 193 | .byte 0xff 194 | .byte 0xff 195 | .byte 0xff 196 | .byte 0xff 197 | .byte 0xff 198 | .byte 0xff 199 | .byte 0xff 200 | .byte 0xff 201 | .byte 0xff 202 | .byte 0xff 203 | .byte 0xff 204 | .byte 0xff 205 | .byte 0xff 206 | .byte 0xff 207 | .byte 0xff 208 | .byte 0xff 209 | .byte 0xff 210 | .byte 0xff 211 | .byte 0xff 212 | .byte 0xff 213 | .byte 0xff 214 | .byte 0xff 215 | .byte 0xff 216 | .byte 0xff 217 | .byte 0xff 218 | .byte 0xff 219 | .byte 0xff 220 | .byte 0xff 221 | .byte 0xff 222 | .byte 0xff 223 | .byte 0xff 224 | .byte 0xff 225 | .byte 0xff 226 | .byte 0xff 227 | .byte 0xff 228 | .byte 0xff 229 | .byte 0xff 230 | .byte 0xff 231 | .byte 0xff 232 | .byte 0xff 233 | .byte 0xff 234 | .byte 0xff 235 | .byte 0xff 236 | .byte 0xff 237 | .byte 0xff 238 | .byte 0xff 239 | .byte 0xff 240 | .byte 0xff 241 | .byte 0xff 242 | .byte 0xff 243 | .byte 0xff 244 | .byte 0xff 245 | .byte 0xff 246 | .byte 0xff 247 | .byte 0xff 248 | .byte 0xff 249 | .byte 0xff 250 | .byte 0xff 251 | .byte 0xff 252 | .byte 0xff 253 | .byte 0xff 254 | .byte 0xff 255 | .byte 0xff 256 | .byte 0xff 257 | .byte 0xff 258 | .byte 0xff 259 | .byte 0xff 260 | .byte 0xff 261 | .byte 0xff 262 | .byte 0xff 263 | .byte 0xff 264 | .byte 0xff 265 | .byte 0xff 266 | .byte 0xff 267 | .byte 0xff 268 | .byte 0xff 269 | .byte 0xff 270 | .byte 0xff 271 | .byte 0xff 272 | .byte 0xff 273 | .byte 0xff 274 | .byte 0xff 275 | .byte 0xff 276 | .byte 0xff 277 | .byte 0xff 278 | .byte 0xff 279 | .byte 0xff 280 | .byte 0xff 281 | .byte 0xff 282 | .byte 0xff 283 | .byte 0xff 284 | .byte 0xff 285 | .byte 0xff 286 | .byte 0xff 287 | .byte 0xff 288 | .byte 0xff 289 | .byte 0xff 290 | .byte 0xff 291 | .byte 0xff 292 | .byte 0xff 293 | .byte 0xff 294 | .byte 0xff 295 | .byte 0xff 296 | .byte 0xff 297 | .byte 0xff 298 | .byte 0xff 299 | .byte 0xff 300 | .byte 0xff 301 | .byte 0xff 302 | .byte 0xff 303 | .byte 0xff 304 | .byte 0xff 305 | .byte 0xff 306 | .byte 0xff 307 | .byte 0xff 308 | .byte 0xff 309 | .byte 0xff 310 | .byte 0xff 311 | .byte 0xff 312 | .byte 0xff 313 | .byte 0xff 314 | .byte 0xff 315 | .byte 0xff 316 | .byte 0xff 317 | .byte 0xff 318 | .byte 0xff 319 | .byte 0xff 320 | .byte 0xff 321 | .byte 0xff 322 | .byte 0xff 323 | .byte 0xff 324 | .byte 0xff 325 | .byte 0xff 326 | .byte 0xff 327 | .byte 0xff 328 | .byte 0xff 329 | .byte 0xff 330 | .byte 0xff 331 | .byte 0xff 332 | .byte 0xff 333 | .byte 0xff 334 | .byte 0xff 335 | .byte 0xff 336 | .byte 0xff 337 | .byte 0xff 338 | .byte 0xff 339 | .byte 0xff 340 | .byte 0xff 341 | .byte 0xff 342 | .byte 0xff 343 | .byte 0xff 344 | .byte 0xff 345 | .byte 0xff 346 | .byte 0xff 347 | .byte 0xff 348 | .byte 0xff 349 | .byte 0xff 350 | .byte 0xff 351 | .byte 0xff 352 | .byte 0xff 353 | .byte 0xff 354 | .byte 0xff 355 | .byte 0xff 356 | .byte 0xff 357 | .byte 0xff 358 | .byte 0xff 359 | .byte 0xff 360 | .byte 0xff 361 | .byte 0xff 362 | .byte 0xff 363 | .byte 0xff 364 | .byte 0xff 365 | .byte 0xff 366 | .byte 0xff 367 | .byte 0xff 368 | .byte 0xff 369 | .byte 0xff 370 | .byte 0xff 371 | .byte 0xff 372 | .byte 0xff 373 | .byte 0xff 374 | .byte 0xff 375 | .byte 0xff 376 | .byte 0xff 377 | .byte 0xff 378 | .byte 0xff 379 | .byte 0xff 380 | .byte 0xff 381 | .byte 0xff 382 | .byte 0xff 383 | .byte 0xff 384 | .byte 0xff 385 | .byte 0xff 386 | .byte 0xff 387 | .byte 0xff 388 | .byte 0xff 389 | .byte 0xff 390 | .byte 0xff 391 | .byte 0xff 392 | .byte 0xff 393 | .byte 0xff 394 | .byte 0xff 395 | .byte 0xff 396 | .byte 0xff 397 | .byte 0xff 398 | .byte 0xff 399 | .byte 0xff 400 | .byte 0xff 401 | .byte 0xff 402 | .byte 0xff 403 | .byte 0xff 404 | .byte 0xff 405 | .byte 0xff 406 | .byte 0xff 407 | .byte 0xff 408 | .byte 0xff 409 | .byte 0xff 410 | .byte 0xff 411 | .byte 0xff 412 | .byte 0xff 413 | .byte 0xff 414 | .byte 0xff 415 | .byte 0xff 416 | .byte 0xff 417 | .byte 0xff 418 | .byte 0xff 419 | .byte 0xff 420 | .byte 0xff 421 | .byte 0xff 422 | .byte 0xff 423 | .byte 0xff 424 | .byte 0xff 425 | .byte 0xff 426 | .byte 0xff 427 | .byte 0xff 428 | .byte 0xff 429 | .byte 0xff 430 | .byte 0xff 431 | .byte 0xff 432 | .byte 0xff 433 | .byte 0xff 434 | .byte 0xff 435 | .byte 0xff 436 | .byte 0xff 437 | .byte 0xff 438 | .byte 0xff 439 | .byte 0xff 440 | .byte 0xff 441 | .byte 0xff 442 | .byte 0xff 443 | .byte 0xff 444 | .byte 0xff 445 | .byte 0xff 446 | .byte 0xff 447 | .byte 0xff 448 | 449 | replicator: 450 | CLD 451 | MOV BX,0x3d7 ; memory top 452 | MOV EDI,ESI 453 | ADD SI,461 ; offset Payload - offset Main 454 | MOV EAX,ESI 455 | ADD EDI,40 ; only for 1st replication 456 | MOV [EDX],EAX ; Por si alguien se esconde en 0x0 o en 0x3ff y le pillo.. 457 | MOV [EBX+36],EAX 458 | Payload: 459 | MOV ESI,EAX ; payload start 460 | MOV CL,0x0A ; loop rep // attack // copy to the last .byte 0xcc 461 | SUB EDI,40+40+3 ; separation ( 40 from last movsd + 40 from new movsd + 3 extra) 462 | JNC Nocheck ; check limits 463 | MOV EDI,EBX 464 | Nocheck: 465 | MOV EAX,EDI 466 | REP MOVSD ; replicator 467 | JMP EAX 468 | .byte 0xcc 469 | .byte 0xcc 470 | .byte 0xcc 471 | .byte 0xcc 472 | .byte 0xcc 473 | .byte 0xcc 474 | .byte 0xcc 475 | .byte 0xcc 476 | .byte 0xcc 477 | .byte 0xcc 478 | .byte 0xcc 479 | .byte 0xcc 480 | .byte 0xcc 481 | .byte 0xcc 482 | .byte 0xcc 483 | .byte 0xcc 484 | .byte 0xcc 485 | .byte 0xcc 486 | .byte 0xcc 487 | .byte 0xcc 488 | .byte 0xcc 489 | .byte 0xcc 490 | 491 | -------------------------------------------------------------------------------- /examples/r2con2020/round2/goyo/gordasco.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; Warrior X86 32 bits by goyo. 2 | ; Despues del RevientaViejas (r2con2018), viene: 'GORDASCO' 3 | ; bot para r2wars (r2con2020) 4 | ; Básicamente un replicator con problemas de peso 5 | 6 | .bits 32 7 | Main: 8 | CALL Boot 9 | Boot: 10 | POP ESI 11 | JMP replicator 12 | # Esto para engordar el binario a 512 bytes y reducir el area de busqueda inicial del otro bot a 512. 13 | # Si es rápido podría encontrar al otro antes de que se mueva si es que se mueve. 14 | 15 | .byte 0xff 16 | .byte 0xff 17 | .byte 0xff 18 | .byte 0xff 19 | .byte 0xff 20 | .byte 0xff 21 | .byte 0xff 22 | .byte 0xff 23 | .byte 0xff 24 | .byte 0xff 25 | .byte 0xff 26 | .byte 0xff 27 | .byte 0xff 28 | .byte 0xff 29 | .byte 0xff 30 | .byte 0xff 31 | .byte 0xff 32 | .byte 0xff 33 | .byte 0xff 34 | .byte 0xff 35 | .byte 0xff 36 | .byte 0xff 37 | .byte 0xff 38 | .byte 0xff 39 | .byte 0xff 40 | .byte 0xff 41 | .byte 0xff 42 | .byte 0xff 43 | .byte 0xff 44 | .byte 0xff 45 | .byte 0xff 46 | .byte 0xff 47 | .byte 0xff 48 | .byte 0xff 49 | .byte 0xff 50 | .byte 0xff 51 | .byte 0xff 52 | .byte 0xff 53 | .byte 0xff 54 | .byte 0xff 55 | .byte 0xff 56 | .byte 0xff 57 | .byte 0xff 58 | .byte 0xff 59 | .byte 0xff 60 | .byte 0xff 61 | .byte 0xff 62 | .byte 0xff 63 | .byte 0xff 64 | .byte 0xff 65 | .byte 0xff 66 | .byte 0xff 67 | .byte 0xff 68 | .byte 0xff 69 | .byte 0xff 70 | .byte 0xff 71 | .byte 0xff 72 | .byte 0xff 73 | .byte 0xff 74 | .byte 0xff 75 | .byte 0xff 76 | .byte 0xff 77 | .byte 0xff 78 | .byte 0xff 79 | .byte 0xff 80 | .byte 0xff 81 | .byte 0xff 82 | .byte 0xff 83 | .byte 0xff 84 | .byte 0xff 85 | .byte 0xff 86 | .byte 0xff 87 | .byte 0xff 88 | .byte 0xff 89 | .byte 0xff 90 | .byte 0xff 91 | .byte 0xff 92 | .byte 0xff 93 | .byte 0xff 94 | .byte 0xff 95 | .byte 0xff 96 | .byte 0xff 97 | .byte 0xff 98 | .byte 0xff 99 | .byte 0xff 100 | .byte 0xff 101 | .byte 0xff 102 | .byte 0xff 103 | .byte 0xff 104 | .byte 0xff 105 | .byte 0xff 106 | .byte 0xff 107 | .byte 0xff 108 | .byte 0xff 109 | .byte 0xff 110 | .byte 0xff 111 | .byte 0xff 112 | .byte 0xff 113 | .byte 0xff 114 | .byte 0xff 115 | .byte 0xff 116 | .byte 0xff 117 | .byte 0xff 118 | .byte 0xff 119 | .byte 0xff 120 | .byte 0xff 121 | .byte 0xff 122 | .byte 0xff 123 | .byte 0xff 124 | .byte 0xff 125 | .byte 0xff 126 | .byte 0xff 127 | .byte 0xff 128 | .byte 0xff 129 | .byte 0xff 130 | .byte 0xff 131 | .byte 0xff 132 | .byte 0xff 133 | .byte 0xff 134 | .byte 0xff 135 | .byte 0xff 136 | .byte 0xff 137 | .byte 0xff 138 | .byte 0xff 139 | .byte 0xff 140 | .byte 0xff 141 | .byte 0xff 142 | .byte 0xff 143 | .byte 0xff 144 | .byte 0xff 145 | .byte 0xff 146 | .byte 0xff 147 | .byte 0xff 148 | .byte 0xff 149 | .byte 0xff 150 | .byte 0xff 151 | .byte 0xff 152 | .byte 0xff 153 | .byte 0xff 154 | .byte 0xff 155 | .byte 0xff 156 | .byte 0xff 157 | .byte 0xff 158 | .byte 0xff 159 | .byte 0xff 160 | .byte 0xff 161 | .byte 0xff 162 | .byte 0xff 163 | .byte 0xff 164 | .byte 0xff 165 | .byte 0xff 166 | .byte 0xff 167 | .byte 0xff 168 | .byte 0xff 169 | .byte 0xff 170 | .byte 0xff 171 | .byte 0xff 172 | .byte 0xff 173 | .byte 0xff 174 | .byte 0xff 175 | .byte 0xff 176 | .byte 0xff 177 | .byte 0xff 178 | .byte 0xff 179 | .byte 0xff 180 | .byte 0xff 181 | .byte 0xff 182 | .byte 0xff 183 | .byte 0xff 184 | .byte 0xff 185 | .byte 0xff 186 | .byte 0xff 187 | .byte 0xff 188 | .byte 0xff 189 | .byte 0xff 190 | .byte 0xff 191 | .byte 0xff 192 | .byte 0xff 193 | .byte 0xff 194 | .byte 0xff 195 | .byte 0xff 196 | .byte 0xff 197 | .byte 0xff 198 | .byte 0xff 199 | .byte 0xff 200 | .byte 0xff 201 | .byte 0xff 202 | .byte 0xff 203 | .byte 0xff 204 | .byte 0xff 205 | .byte 0xff 206 | .byte 0xff 207 | .byte 0xff 208 | .byte 0xff 209 | .byte 0xff 210 | .byte 0xff 211 | .byte 0xff 212 | .byte 0xff 213 | .byte 0xff 214 | .byte 0xff 215 | .byte 0xff 216 | .byte 0xff 217 | .byte 0xff 218 | .byte 0xff 219 | .byte 0xff 220 | .byte 0xff 221 | .byte 0xff 222 | .byte 0xff 223 | .byte 0xff 224 | .byte 0xff 225 | .byte 0xff 226 | .byte 0xff 227 | .byte 0xff 228 | .byte 0xff 229 | .byte 0xff 230 | .byte 0xff 231 | .byte 0xff 232 | .byte 0xff 233 | .byte 0xff 234 | .byte 0xff 235 | .byte 0xff 236 | .byte 0xff 237 | .byte 0xff 238 | .byte 0xff 239 | .byte 0xff 240 | .byte 0xff 241 | .byte 0xff 242 | .byte 0xff 243 | .byte 0xff 244 | .byte 0xff 245 | .byte 0xff 246 | .byte 0xff 247 | .byte 0xff 248 | .byte 0xff 249 | .byte 0xff 250 | .byte 0xff 251 | .byte 0xff 252 | .byte 0xff 253 | .byte 0xff 254 | .byte 0xff 255 | .byte 0xff 256 | .byte 0xff 257 | .byte 0xff 258 | .byte 0xff 259 | .byte 0xff 260 | .byte 0xff 261 | .byte 0xff 262 | .byte 0xff 263 | .byte 0xff 264 | .byte 0xff 265 | .byte 0xff 266 | .byte 0xff 267 | .byte 0xff 268 | .byte 0xff 269 | .byte 0xff 270 | .byte 0xff 271 | .byte 0xff 272 | .byte 0xff 273 | .byte 0xff 274 | .byte 0xff 275 | .byte 0xff 276 | .byte 0xff 277 | .byte 0xff 278 | .byte 0xff 279 | .byte 0xff 280 | .byte 0xff 281 | .byte 0xff 282 | .byte 0xff 283 | .byte 0xff 284 | .byte 0xff 285 | .byte 0xff 286 | .byte 0xff 287 | .byte 0xff 288 | .byte 0xff 289 | .byte 0xff 290 | .byte 0xff 291 | .byte 0xff 292 | .byte 0xff 293 | .byte 0xff 294 | .byte 0xff 295 | .byte 0xff 296 | .byte 0xff 297 | .byte 0xff 298 | .byte 0xff 299 | .byte 0xff 300 | .byte 0xff 301 | .byte 0xff 302 | .byte 0xff 303 | .byte 0xff 304 | .byte 0xff 305 | .byte 0xff 306 | .byte 0xff 307 | .byte 0xff 308 | .byte 0xff 309 | .byte 0xff 310 | .byte 0xff 311 | .byte 0xff 312 | .byte 0xff 313 | .byte 0xff 314 | .byte 0xff 315 | .byte 0xff 316 | .byte 0xff 317 | .byte 0xff 318 | .byte 0xff 319 | .byte 0xff 320 | .byte 0xff 321 | .byte 0xff 322 | .byte 0xff 323 | .byte 0xff 324 | .byte 0xff 325 | .byte 0xff 326 | .byte 0xff 327 | .byte 0xff 328 | .byte 0xff 329 | .byte 0xff 330 | .byte 0xff 331 | .byte 0xff 332 | .byte 0xff 333 | .byte 0xff 334 | .byte 0xff 335 | .byte 0xff 336 | .byte 0xff 337 | .byte 0xff 338 | .byte 0xff 339 | .byte 0xff 340 | .byte 0xff 341 | .byte 0xff 342 | .byte 0xff 343 | .byte 0xff 344 | .byte 0xff 345 | .byte 0xff 346 | .byte 0xff 347 | .byte 0xff 348 | .byte 0xff 349 | .byte 0xff 350 | .byte 0xff 351 | .byte 0xff 352 | .byte 0xff 353 | .byte 0xff 354 | .byte 0xff 355 | .byte 0xff 356 | .byte 0xff 357 | .byte 0xff 358 | .byte 0xff 359 | .byte 0xff 360 | .byte 0xff 361 | .byte 0xff 362 | .byte 0xff 363 | .byte 0xff 364 | .byte 0xff 365 | .byte 0xff 366 | .byte 0xff 367 | .byte 0xff 368 | .byte 0xff 369 | .byte 0xff 370 | .byte 0xff 371 | .byte 0xff 372 | .byte 0xff 373 | .byte 0xff 374 | .byte 0xff 375 | .byte 0xff 376 | .byte 0xff 377 | .byte 0xff 378 | .byte 0xff 379 | .byte 0xff 380 | .byte 0xff 381 | .byte 0xff 382 | .byte 0xff 383 | .byte 0xff 384 | .byte 0xff 385 | .byte 0xff 386 | .byte 0xff 387 | .byte 0xff 388 | .byte 0xff 389 | .byte 0xff 390 | .byte 0xff 391 | .byte 0xff 392 | .byte 0xff 393 | .byte 0xff 394 | .byte 0xff 395 | .byte 0xff 396 | .byte 0xff 397 | .byte 0xff 398 | .byte 0xff 399 | .byte 0xff 400 | .byte 0xff 401 | .byte 0xff 402 | .byte 0xff 403 | .byte 0xff 404 | .byte 0xff 405 | .byte 0xff 406 | .byte 0xff 407 | .byte 0xff 408 | .byte 0xff 409 | .byte 0xff 410 | .byte 0xff 411 | .byte 0xff 412 | .byte 0xff 413 | .byte 0xff 414 | .byte 0xff 415 | .byte 0xff 416 | .byte 0xff 417 | .byte 0xff 418 | .byte 0xff 419 | .byte 0xff 420 | .byte 0xff 421 | .byte 0xff 422 | .byte 0xff 423 | .byte 0xff 424 | .byte 0xff 425 | .byte 0xff 426 | .byte 0xff 427 | .byte 0xff 428 | .byte 0xff 429 | .byte 0xff 430 | .byte 0xff 431 | .byte 0xff 432 | .byte 0xff 433 | .byte 0xff 434 | .byte 0xff 435 | .byte 0xff 436 | .byte 0xff 437 | .byte 0xff 438 | .byte 0xff 439 | .byte 0xff 440 | .byte 0xff 441 | .byte 0xff 442 | .byte 0xff 443 | .byte 0xff 444 | .byte 0xff 445 | .byte 0xff 446 | .byte 0xff 447 | .byte 0xff 448 | 449 | replicator: 450 | CLD 451 | MOV BX,0x3d7 ; memory top 452 | MOV EDI,ESI 453 | ADD SI,461 ; offset Payload - offset Main 454 | MOV EAX,ESI 455 | ADD EDI,40 ; only for 1st replication 456 | MOV [EDX],EAX ; Por si alguien se esconde en 0x0 o en 0x3ff y le pillo.. 457 | MOV [EBX+36],EAX 458 | Payload: 459 | MOV ESI,EAX ; payload start 460 | MOV CL,0x0A ; loop rep // attack // copy to the last .byte 0xcc 461 | SUB EDI,40+40+3 ; separation ( 40 from last movsd + 40 from new movsd + 3 extra) 462 | JNC Nocheck ; check limits 463 | MOV EDI,EBX 464 | Nocheck: 465 | MOV EAX,EDI 466 | REP MOVSD ; replicator 467 | JMP EAX 468 | .byte 0xcc 469 | .byte 0xcc 470 | .byte 0xcc 471 | .byte 0xcc 472 | .byte 0xcc 473 | .byte 0xcc 474 | .byte 0xcc 475 | .byte 0xcc 476 | .byte 0xcc 477 | .byte 0xcc 478 | .byte 0xcc 479 | .byte 0xcc 480 | .byte 0xcc 481 | .byte 0xcc 482 | .byte 0xcc 483 | .byte 0xcc 484 | .byte 0xcc 485 | .byte 0xcc 486 | .byte 0xcc 487 | .byte 0xcc 488 | .byte 0xcc 489 | .byte 0xcc 490 | 491 | -------------------------------------------------------------------------------- /examples/r2con2020/round3/goyo/gordasco.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; Warrior X86 32 bits by goyo. 2 | ; Despues del RevientaViejas (r2con2018), viene: 'GORDASCO' 3 | ; bot para r2wars (r2con2020) 4 | ; Básicamente un replicator con problemas de peso 5 | 6 | .bits 32 7 | Main: 8 | CALL Boot 9 | Boot: 10 | POP ESI 11 | JMP replicator 12 | # Esto para engordar el binario a 512 bytes y reducir el area de busqueda inicial del otro bot a 512. 13 | # Si es rápido podría encontrar al otro antes de que se mueva si es que se mueve. 14 | 15 | .byte 0xff 16 | .byte 0xff 17 | .byte 0xff 18 | .byte 0xff 19 | .byte 0xff 20 | .byte 0xff 21 | .byte 0xff 22 | .byte 0xff 23 | .byte 0xff 24 | .byte 0xff 25 | .byte 0xff 26 | .byte 0xff 27 | .byte 0xff 28 | .byte 0xff 29 | .byte 0xff 30 | .byte 0xff 31 | .byte 0xff 32 | .byte 0xff 33 | .byte 0xff 34 | .byte 0xff 35 | .byte 0xff 36 | .byte 0xff 37 | .byte 0xff 38 | .byte 0xff 39 | .byte 0xff 40 | .byte 0xff 41 | .byte 0xff 42 | .byte 0xff 43 | .byte 0xff 44 | .byte 0xff 45 | .byte 0xff 46 | .byte 0xff 47 | .byte 0xff 48 | .byte 0xff 49 | .byte 0xff 50 | .byte 0xff 51 | .byte 0xff 52 | .byte 0xff 53 | .byte 0xff 54 | .byte 0xff 55 | .byte 0xff 56 | .byte 0xff 57 | .byte 0xff 58 | .byte 0xff 59 | .byte 0xff 60 | .byte 0xff 61 | .byte 0xff 62 | .byte 0xff 63 | .byte 0xff 64 | .byte 0xff 65 | .byte 0xff 66 | .byte 0xff 67 | .byte 0xff 68 | .byte 0xff 69 | .byte 0xff 70 | .byte 0xff 71 | .byte 0xff 72 | .byte 0xff 73 | .byte 0xff 74 | .byte 0xff 75 | .byte 0xff 76 | .byte 0xff 77 | .byte 0xff 78 | .byte 0xff 79 | .byte 0xff 80 | .byte 0xff 81 | .byte 0xff 82 | .byte 0xff 83 | .byte 0xff 84 | .byte 0xff 85 | .byte 0xff 86 | .byte 0xff 87 | .byte 0xff 88 | .byte 0xff 89 | .byte 0xff 90 | .byte 0xff 91 | .byte 0xff 92 | .byte 0xff 93 | .byte 0xff 94 | .byte 0xff 95 | .byte 0xff 96 | .byte 0xff 97 | .byte 0xff 98 | .byte 0xff 99 | .byte 0xff 100 | .byte 0xff 101 | .byte 0xff 102 | .byte 0xff 103 | .byte 0xff 104 | .byte 0xff 105 | .byte 0xff 106 | .byte 0xff 107 | .byte 0xff 108 | .byte 0xff 109 | .byte 0xff 110 | .byte 0xff 111 | .byte 0xff 112 | .byte 0xff 113 | .byte 0xff 114 | .byte 0xff 115 | .byte 0xff 116 | .byte 0xff 117 | .byte 0xff 118 | .byte 0xff 119 | .byte 0xff 120 | .byte 0xff 121 | .byte 0xff 122 | .byte 0xff 123 | .byte 0xff 124 | .byte 0xff 125 | .byte 0xff 126 | .byte 0xff 127 | .byte 0xff 128 | .byte 0xff 129 | .byte 0xff 130 | .byte 0xff 131 | .byte 0xff 132 | .byte 0xff 133 | .byte 0xff 134 | .byte 0xff 135 | .byte 0xff 136 | .byte 0xff 137 | .byte 0xff 138 | .byte 0xff 139 | .byte 0xff 140 | .byte 0xff 141 | .byte 0xff 142 | .byte 0xff 143 | .byte 0xff 144 | .byte 0xff 145 | .byte 0xff 146 | .byte 0xff 147 | .byte 0xff 148 | .byte 0xff 149 | .byte 0xff 150 | .byte 0xff 151 | .byte 0xff 152 | .byte 0xff 153 | .byte 0xff 154 | .byte 0xff 155 | .byte 0xff 156 | .byte 0xff 157 | .byte 0xff 158 | .byte 0xff 159 | .byte 0xff 160 | .byte 0xff 161 | .byte 0xff 162 | .byte 0xff 163 | .byte 0xff 164 | .byte 0xff 165 | .byte 0xff 166 | .byte 0xff 167 | .byte 0xff 168 | .byte 0xff 169 | .byte 0xff 170 | .byte 0xff 171 | .byte 0xff 172 | .byte 0xff 173 | .byte 0xff 174 | .byte 0xff 175 | .byte 0xff 176 | .byte 0xff 177 | .byte 0xff 178 | .byte 0xff 179 | .byte 0xff 180 | .byte 0xff 181 | .byte 0xff 182 | .byte 0xff 183 | .byte 0xff 184 | .byte 0xff 185 | .byte 0xff 186 | .byte 0xff 187 | .byte 0xff 188 | .byte 0xff 189 | .byte 0xff 190 | .byte 0xff 191 | .byte 0xff 192 | .byte 0xff 193 | .byte 0xff 194 | .byte 0xff 195 | .byte 0xff 196 | .byte 0xff 197 | .byte 0xff 198 | .byte 0xff 199 | .byte 0xff 200 | .byte 0xff 201 | .byte 0xff 202 | .byte 0xff 203 | .byte 0xff 204 | .byte 0xff 205 | .byte 0xff 206 | .byte 0xff 207 | .byte 0xff 208 | .byte 0xff 209 | .byte 0xff 210 | .byte 0xff 211 | .byte 0xff 212 | .byte 0xff 213 | .byte 0xff 214 | .byte 0xff 215 | .byte 0xff 216 | .byte 0xff 217 | .byte 0xff 218 | .byte 0xff 219 | .byte 0xff 220 | .byte 0xff 221 | .byte 0xff 222 | .byte 0xff 223 | .byte 0xff 224 | .byte 0xff 225 | .byte 0xff 226 | .byte 0xff 227 | .byte 0xff 228 | .byte 0xff 229 | .byte 0xff 230 | .byte 0xff 231 | .byte 0xff 232 | .byte 0xff 233 | .byte 0xff 234 | .byte 0xff 235 | .byte 0xff 236 | .byte 0xff 237 | .byte 0xff 238 | .byte 0xff 239 | .byte 0xff 240 | .byte 0xff 241 | .byte 0xff 242 | .byte 0xff 243 | .byte 0xff 244 | .byte 0xff 245 | .byte 0xff 246 | .byte 0xff 247 | .byte 0xff 248 | .byte 0xff 249 | .byte 0xff 250 | .byte 0xff 251 | .byte 0xff 252 | .byte 0xff 253 | .byte 0xff 254 | .byte 0xff 255 | .byte 0xff 256 | .byte 0xff 257 | .byte 0xff 258 | .byte 0xff 259 | .byte 0xff 260 | .byte 0xff 261 | .byte 0xff 262 | .byte 0xff 263 | .byte 0xff 264 | .byte 0xff 265 | .byte 0xff 266 | .byte 0xff 267 | .byte 0xff 268 | .byte 0xff 269 | .byte 0xff 270 | .byte 0xff 271 | .byte 0xff 272 | .byte 0xff 273 | .byte 0xff 274 | .byte 0xff 275 | .byte 0xff 276 | .byte 0xff 277 | .byte 0xff 278 | .byte 0xff 279 | .byte 0xff 280 | .byte 0xff 281 | .byte 0xff 282 | .byte 0xff 283 | .byte 0xff 284 | .byte 0xff 285 | .byte 0xff 286 | .byte 0xff 287 | .byte 0xff 288 | .byte 0xff 289 | .byte 0xff 290 | .byte 0xff 291 | .byte 0xff 292 | .byte 0xff 293 | .byte 0xff 294 | .byte 0xff 295 | .byte 0xff 296 | .byte 0xff 297 | .byte 0xff 298 | .byte 0xff 299 | .byte 0xff 300 | .byte 0xff 301 | .byte 0xff 302 | .byte 0xff 303 | .byte 0xff 304 | .byte 0xff 305 | .byte 0xff 306 | .byte 0xff 307 | .byte 0xff 308 | .byte 0xff 309 | .byte 0xff 310 | .byte 0xff 311 | .byte 0xff 312 | .byte 0xff 313 | .byte 0xff 314 | .byte 0xff 315 | .byte 0xff 316 | .byte 0xff 317 | .byte 0xff 318 | .byte 0xff 319 | .byte 0xff 320 | .byte 0xff 321 | .byte 0xff 322 | .byte 0xff 323 | .byte 0xff 324 | .byte 0xff 325 | .byte 0xff 326 | .byte 0xff 327 | .byte 0xff 328 | .byte 0xff 329 | .byte 0xff 330 | .byte 0xff 331 | .byte 0xff 332 | .byte 0xff 333 | .byte 0xff 334 | .byte 0xff 335 | .byte 0xff 336 | .byte 0xff 337 | .byte 0xff 338 | .byte 0xff 339 | .byte 0xff 340 | .byte 0xff 341 | .byte 0xff 342 | .byte 0xff 343 | .byte 0xff 344 | .byte 0xff 345 | .byte 0xff 346 | .byte 0xff 347 | .byte 0xff 348 | .byte 0xff 349 | .byte 0xff 350 | .byte 0xff 351 | .byte 0xff 352 | .byte 0xff 353 | .byte 0xff 354 | .byte 0xff 355 | .byte 0xff 356 | .byte 0xff 357 | .byte 0xff 358 | .byte 0xff 359 | .byte 0xff 360 | .byte 0xff 361 | .byte 0xff 362 | .byte 0xff 363 | .byte 0xff 364 | .byte 0xff 365 | .byte 0xff 366 | .byte 0xff 367 | .byte 0xff 368 | .byte 0xff 369 | .byte 0xff 370 | .byte 0xff 371 | .byte 0xff 372 | .byte 0xff 373 | .byte 0xff 374 | .byte 0xff 375 | .byte 0xff 376 | .byte 0xff 377 | .byte 0xff 378 | .byte 0xff 379 | .byte 0xff 380 | .byte 0xff 381 | .byte 0xff 382 | .byte 0xff 383 | .byte 0xff 384 | .byte 0xff 385 | .byte 0xff 386 | .byte 0xff 387 | .byte 0xff 388 | .byte 0xff 389 | .byte 0xff 390 | .byte 0xff 391 | .byte 0xff 392 | .byte 0xff 393 | .byte 0xff 394 | .byte 0xff 395 | .byte 0xff 396 | .byte 0xff 397 | .byte 0xff 398 | .byte 0xff 399 | .byte 0xff 400 | .byte 0xff 401 | .byte 0xff 402 | .byte 0xff 403 | .byte 0xff 404 | .byte 0xff 405 | .byte 0xff 406 | .byte 0xff 407 | .byte 0xff 408 | .byte 0xff 409 | .byte 0xff 410 | .byte 0xff 411 | .byte 0xff 412 | .byte 0xff 413 | .byte 0xff 414 | .byte 0xff 415 | .byte 0xff 416 | .byte 0xff 417 | .byte 0xff 418 | .byte 0xff 419 | .byte 0xff 420 | .byte 0xff 421 | .byte 0xff 422 | .byte 0xff 423 | .byte 0xff 424 | .byte 0xff 425 | .byte 0xff 426 | .byte 0xff 427 | .byte 0xff 428 | .byte 0xff 429 | .byte 0xff 430 | .byte 0xff 431 | .byte 0xff 432 | .byte 0xff 433 | .byte 0xff 434 | .byte 0xff 435 | .byte 0xff 436 | .byte 0xff 437 | .byte 0xff 438 | .byte 0xff 439 | .byte 0xff 440 | .byte 0xff 441 | .byte 0xff 442 | .byte 0xff 443 | .byte 0xff 444 | .byte 0xff 445 | .byte 0xff 446 | .byte 0xff 447 | .byte 0xff 448 | 449 | replicator: 450 | CLD 451 | MOV BX,0x3d7 ; memory top 452 | MOV EDI,ESI 453 | ADD SI,461 ; offset Payload - offset Main 454 | MOV EAX,ESI 455 | ADD EDI,40 ; only for 1st replication 456 | MOV [EDX],EAX ; Por si alguien se esconde en 0x0 o en 0x3ff y le pillo.. 457 | MOV [EBX+36],EAX 458 | Payload: 459 | MOV ESI,EAX ; payload start 460 | MOV CL,0x0A ; loop rep // attack // copy to the last .byte 0xcc 461 | SUB EDI,40+40+3 ; separation ( 40 from last movsd + 40 from new movsd + 3 extra) 462 | JNC Nocheck ; check limits 463 | MOV EDI,EBX 464 | Nocheck: 465 | MOV EAX,EDI 466 | REP MOVSD ; replicator 467 | JMP EAX 468 | .byte 0xcc 469 | .byte 0xcc 470 | .byte 0xcc 471 | .byte 0xcc 472 | .byte 0xcc 473 | .byte 0xcc 474 | .byte 0xcc 475 | .byte 0xcc 476 | .byte 0xcc 477 | .byte 0xcc 478 | .byte 0xcc 479 | .byte 0xcc 480 | .byte 0xcc 481 | .byte 0xcc 482 | .byte 0xcc 483 | .byte 0xcc 484 | .byte 0xcc 485 | .byte 0xcc 486 | .byte 0xcc 487 | .byte 0xcc 488 | .byte 0xcc 489 | .byte 0xcc 490 | 491 | -------------------------------------------------------------------------------- /examples/r2con2020/round4/goyo/gordasco.x86-32.asm: -------------------------------------------------------------------------------- 1 | ; Warrior X86 32 bits by goyo. 2 | ; Despues del RevientaViejas (r2con2018), viene: 'GORDASCO' 3 | ; bot para r2wars (r2con2020) 4 | ; Básicamente un replicator con problemas de peso 5 | 6 | .bits 32 7 | Main: 8 | CALL Boot 9 | Boot: 10 | POP ESI 11 | JMP replicator 12 | # Esto para engordar el binario a 512 bytes y reducir el area de busqueda inicial del otro bot a 512. 13 | # Si es rápido podría encontrar al otro antes de que se mueva si es que se mueve. 14 | 15 | .byte 0xff 16 | .byte 0xff 17 | .byte 0xff 18 | .byte 0xff 19 | .byte 0xff 20 | .byte 0xff 21 | .byte 0xff 22 | .byte 0xff 23 | .byte 0xff 24 | .byte 0xff 25 | .byte 0xff 26 | .byte 0xff 27 | .byte 0xff 28 | .byte 0xff 29 | .byte 0xff 30 | .byte 0xff 31 | .byte 0xff 32 | .byte 0xff 33 | .byte 0xff 34 | .byte 0xff 35 | .byte 0xff 36 | .byte 0xff 37 | .byte 0xff 38 | .byte 0xff 39 | .byte 0xff 40 | .byte 0xff 41 | .byte 0xff 42 | .byte 0xff 43 | .byte 0xff 44 | .byte 0xff 45 | .byte 0xff 46 | .byte 0xff 47 | .byte 0xff 48 | .byte 0xff 49 | .byte 0xff 50 | .byte 0xff 51 | .byte 0xff 52 | .byte 0xff 53 | .byte 0xff 54 | .byte 0xff 55 | .byte 0xff 56 | .byte 0xff 57 | .byte 0xff 58 | .byte 0xff 59 | .byte 0xff 60 | .byte 0xff 61 | .byte 0xff 62 | .byte 0xff 63 | .byte 0xff 64 | .byte 0xff 65 | .byte 0xff 66 | .byte 0xff 67 | .byte 0xff 68 | .byte 0xff 69 | .byte 0xff 70 | .byte 0xff 71 | .byte 0xff 72 | .byte 0xff 73 | .byte 0xff 74 | .byte 0xff 75 | .byte 0xff 76 | .byte 0xff 77 | .byte 0xff 78 | .byte 0xff 79 | .byte 0xff 80 | .byte 0xff 81 | .byte 0xff 82 | .byte 0xff 83 | .byte 0xff 84 | .byte 0xff 85 | .byte 0xff 86 | .byte 0xff 87 | .byte 0xff 88 | .byte 0xff 89 | .byte 0xff 90 | .byte 0xff 91 | .byte 0xff 92 | .byte 0xff 93 | .byte 0xff 94 | .byte 0xff 95 | .byte 0xff 96 | .byte 0xff 97 | .byte 0xff 98 | .byte 0xff 99 | .byte 0xff 100 | .byte 0xff 101 | .byte 0xff 102 | .byte 0xff 103 | .byte 0xff 104 | .byte 0xff 105 | .byte 0xff 106 | .byte 0xff 107 | .byte 0xff 108 | .byte 0xff 109 | .byte 0xff 110 | .byte 0xff 111 | .byte 0xff 112 | .byte 0xff 113 | .byte 0xff 114 | .byte 0xff 115 | .byte 0xff 116 | .byte 0xff 117 | .byte 0xff 118 | .byte 0xff 119 | .byte 0xff 120 | .byte 0xff 121 | .byte 0xff 122 | .byte 0xff 123 | .byte 0xff 124 | .byte 0xff 125 | .byte 0xff 126 | .byte 0xff 127 | .byte 0xff 128 | .byte 0xff 129 | .byte 0xff 130 | .byte 0xff 131 | .byte 0xff 132 | .byte 0xff 133 | .byte 0xff 134 | .byte 0xff 135 | .byte 0xff 136 | .byte 0xff 137 | .byte 0xff 138 | .byte 0xff 139 | .byte 0xff 140 | .byte 0xff 141 | .byte 0xff 142 | .byte 0xff 143 | .byte 0xff 144 | .byte 0xff 145 | .byte 0xff 146 | .byte 0xff 147 | .byte 0xff 148 | .byte 0xff 149 | .byte 0xff 150 | .byte 0xff 151 | .byte 0xff 152 | .byte 0xff 153 | .byte 0xff 154 | .byte 0xff 155 | .byte 0xff 156 | .byte 0xff 157 | .byte 0xff 158 | .byte 0xff 159 | .byte 0xff 160 | .byte 0xff 161 | .byte 0xff 162 | .byte 0xff 163 | .byte 0xff 164 | .byte 0xff 165 | .byte 0xff 166 | .byte 0xff 167 | .byte 0xff 168 | .byte 0xff 169 | .byte 0xff 170 | .byte 0xff 171 | .byte 0xff 172 | .byte 0xff 173 | .byte 0xff 174 | .byte 0xff 175 | .byte 0xff 176 | .byte 0xff 177 | .byte 0xff 178 | .byte 0xff 179 | .byte 0xff 180 | .byte 0xff 181 | .byte 0xff 182 | .byte 0xff 183 | .byte 0xff 184 | .byte 0xff 185 | .byte 0xff 186 | .byte 0xff 187 | .byte 0xff 188 | .byte 0xff 189 | .byte 0xff 190 | .byte 0xff 191 | .byte 0xff 192 | .byte 0xff 193 | .byte 0xff 194 | .byte 0xff 195 | .byte 0xff 196 | .byte 0xff 197 | .byte 0xff 198 | .byte 0xff 199 | .byte 0xff 200 | .byte 0xff 201 | .byte 0xff 202 | .byte 0xff 203 | .byte 0xff 204 | .byte 0xff 205 | .byte 0xff 206 | .byte 0xff 207 | .byte 0xff 208 | .byte 0xff 209 | .byte 0xff 210 | .byte 0xff 211 | .byte 0xff 212 | .byte 0xff 213 | .byte 0xff 214 | .byte 0xff 215 | .byte 0xff 216 | .byte 0xff 217 | .byte 0xff 218 | .byte 0xff 219 | .byte 0xff 220 | .byte 0xff 221 | .byte 0xff 222 | .byte 0xff 223 | .byte 0xff 224 | .byte 0xff 225 | .byte 0xff 226 | .byte 0xff 227 | .byte 0xff 228 | .byte 0xff 229 | .byte 0xff 230 | .byte 0xff 231 | .byte 0xff 232 | .byte 0xff 233 | .byte 0xff 234 | .byte 0xff 235 | .byte 0xff 236 | .byte 0xff 237 | .byte 0xff 238 | .byte 0xff 239 | .byte 0xff 240 | .byte 0xff 241 | .byte 0xff 242 | .byte 0xff 243 | .byte 0xff 244 | .byte 0xff 245 | .byte 0xff 246 | .byte 0xff 247 | .byte 0xff 248 | .byte 0xff 249 | .byte 0xff 250 | .byte 0xff 251 | .byte 0xff 252 | .byte 0xff 253 | .byte 0xff 254 | .byte 0xff 255 | .byte 0xff 256 | .byte 0xff 257 | .byte 0xff 258 | .byte 0xff 259 | .byte 0xff 260 | .byte 0xff 261 | .byte 0xff 262 | .byte 0xff 263 | .byte 0xff 264 | .byte 0xff 265 | .byte 0xff 266 | .byte 0xff 267 | .byte 0xff 268 | .byte 0xff 269 | .byte 0xff 270 | .byte 0xff 271 | .byte 0xff 272 | .byte 0xff 273 | .byte 0xff 274 | .byte 0xff 275 | .byte 0xff 276 | .byte 0xff 277 | .byte 0xff 278 | .byte 0xff 279 | .byte 0xff 280 | .byte 0xff 281 | .byte 0xff 282 | .byte 0xff 283 | .byte 0xff 284 | .byte 0xff 285 | .byte 0xff 286 | .byte 0xff 287 | .byte 0xff 288 | .byte 0xff 289 | .byte 0xff 290 | .byte 0xff 291 | .byte 0xff 292 | .byte 0xff 293 | .byte 0xff 294 | .byte 0xff 295 | .byte 0xff 296 | .byte 0xff 297 | .byte 0xff 298 | .byte 0xff 299 | .byte 0xff 300 | .byte 0xff 301 | .byte 0xff 302 | .byte 0xff 303 | .byte 0xff 304 | .byte 0xff 305 | .byte 0xff 306 | .byte 0xff 307 | .byte 0xff 308 | .byte 0xff 309 | .byte 0xff 310 | .byte 0xff 311 | .byte 0xff 312 | .byte 0xff 313 | .byte 0xff 314 | .byte 0xff 315 | .byte 0xff 316 | .byte 0xff 317 | .byte 0xff 318 | .byte 0xff 319 | .byte 0xff 320 | .byte 0xff 321 | .byte 0xff 322 | .byte 0xff 323 | .byte 0xff 324 | .byte 0xff 325 | .byte 0xff 326 | .byte 0xff 327 | .byte 0xff 328 | .byte 0xff 329 | .byte 0xff 330 | .byte 0xff 331 | .byte 0xff 332 | .byte 0xff 333 | .byte 0xff 334 | .byte 0xff 335 | .byte 0xff 336 | .byte 0xff 337 | .byte 0xff 338 | .byte 0xff 339 | .byte 0xff 340 | .byte 0xff 341 | .byte 0xff 342 | .byte 0xff 343 | .byte 0xff 344 | .byte 0xff 345 | .byte 0xff 346 | .byte 0xff 347 | .byte 0xff 348 | .byte 0xff 349 | .byte 0xff 350 | .byte 0xff 351 | .byte 0xff 352 | .byte 0xff 353 | .byte 0xff 354 | .byte 0xff 355 | .byte 0xff 356 | .byte 0xff 357 | .byte 0xff 358 | .byte 0xff 359 | .byte 0xff 360 | .byte 0xff 361 | .byte 0xff 362 | .byte 0xff 363 | .byte 0xff 364 | .byte 0xff 365 | .byte 0xff 366 | .byte 0xff 367 | .byte 0xff 368 | .byte 0xff 369 | .byte 0xff 370 | .byte 0xff 371 | .byte 0xff 372 | .byte 0xff 373 | .byte 0xff 374 | .byte 0xff 375 | .byte 0xff 376 | .byte 0xff 377 | .byte 0xff 378 | .byte 0xff 379 | .byte 0xff 380 | .byte 0xff 381 | .byte 0xff 382 | .byte 0xff 383 | .byte 0xff 384 | .byte 0xff 385 | .byte 0xff 386 | .byte 0xff 387 | .byte 0xff 388 | .byte 0xff 389 | .byte 0xff 390 | .byte 0xff 391 | .byte 0xff 392 | .byte 0xff 393 | .byte 0xff 394 | .byte 0xff 395 | .byte 0xff 396 | .byte 0xff 397 | .byte 0xff 398 | .byte 0xff 399 | .byte 0xff 400 | .byte 0xff 401 | .byte 0xff 402 | .byte 0xff 403 | .byte 0xff 404 | .byte 0xff 405 | .byte 0xff 406 | .byte 0xff 407 | .byte 0xff 408 | .byte 0xff 409 | .byte 0xff 410 | .byte 0xff 411 | .byte 0xff 412 | .byte 0xff 413 | .byte 0xff 414 | .byte 0xff 415 | .byte 0xff 416 | .byte 0xff 417 | .byte 0xff 418 | .byte 0xff 419 | .byte 0xff 420 | .byte 0xff 421 | .byte 0xff 422 | .byte 0xff 423 | .byte 0xff 424 | .byte 0xff 425 | .byte 0xff 426 | .byte 0xff 427 | .byte 0xff 428 | .byte 0xff 429 | .byte 0xff 430 | .byte 0xff 431 | .byte 0xff 432 | .byte 0xff 433 | .byte 0xff 434 | .byte 0xff 435 | .byte 0xff 436 | .byte 0xff 437 | .byte 0xff 438 | .byte 0xff 439 | .byte 0xff 440 | .byte 0xff 441 | .byte 0xff 442 | .byte 0xff 443 | .byte 0xff 444 | .byte 0xff 445 | .byte 0xff 446 | .byte 0xff 447 | .byte 0xff 448 | 449 | replicator: 450 | CLD 451 | MOV BX,0x3d7 ; memory top 452 | MOV EDI,ESI 453 | ADD SI,461 ; offset Payload - offset Main 454 | MOV EAX,ESI 455 | ADD EDI,40 ; only for 1st replication 456 | MOV [EDX],EAX ; Por si alguien se esconde en 0x0 o en 0x3ff y le pillo.. 457 | MOV [EBX+36],EAX 458 | Payload: 459 | MOV ESI,EAX ; payload start 460 | MOV CL,0x0A ; loop rep // attack // copy to the last .byte 0xcc 461 | SUB EDI,40+40+3 ; separation ( 40 from last movsd + 40 from new movsd + 3 extra) 462 | JNC Nocheck ; check limits 463 | MOV EDI,EBX 464 | Nocheck: 465 | MOV EAX,EDI 466 | REP MOVSD ; replicator 467 | JMP EAX 468 | .byte 0xcc 469 | .byte 0xcc 470 | .byte 0xcc 471 | .byte 0xcc 472 | .byte 0xcc 473 | .byte 0xcc 474 | .byte 0xcc 475 | .byte 0xcc 476 | .byte 0xcc 477 | .byte 0xcc 478 | .byte 0xcc 479 | .byte 0xcc 480 | .byte 0xcc 481 | .byte 0xcc 482 | .byte 0xcc 483 | .byte 0xcc 484 | .byte 0xcc 485 | .byte 0xcc 486 | .byte 0xcc 487 | .byte 0xcc 488 | .byte 0xcc 489 | .byte 0xcc 490 | 491 | -------------------------------------------------------------------------------- /csharp/packages/System.Runtime.InteropServices.RuntimeInformation.4.3.0/dotnet_library_license.txt: -------------------------------------------------------------------------------- 1 | 2 | MICROSOFT SOFTWARE LICENSE TERMS 3 | 4 | 5 | MICROSOFT .NET LIBRARY 6 | 7 | These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. Please read them. They apply to the software named above, which includes the media on which you received it, if any. The terms also apply to any Microsoft 8 | 9 | · updates, 10 | 11 | · supplements, 12 | 13 | · Internet-based services, and 14 | 15 | · support services 16 | 17 | for this software, unless other terms accompany those items. If so, those terms apply. 18 | 19 | BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE. 20 | 21 | 22 | IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE PERPETUAL RIGHTS BELOW. 23 | 24 | 1. INSTALLATION AND USE RIGHTS. 25 | 26 | a. Installation and Use. You may install and use any number of copies of the software to design, develop and test your programs. 27 | 28 | b. Third Party Programs. The software may include third party programs that Microsoft, not the third party, licenses to you under this agreement. Notices, if any, for the third party program are included for your information only. 29 | 30 | 2. ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS. 31 | 32 | a. DISTRIBUTABLE CODE. The software is comprised of Distributable Code. “Distributable Code” is code that you are permitted to distribute in programs you develop if you comply with the terms below. 33 | 34 | i. Right to Use and Distribute. 35 | 36 | · You may copy and distribute the object code form of the software. 37 | 38 | · Third Party Distribution. You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs. 39 | 40 | ii. Distribution Requirements. For any Distributable Code you distribute, you must 41 | 42 | · add significant primary functionality to it in your programs; 43 | 44 | · require distributors and external end users to agree to terms that protect it at least as much as this agreement; 45 | 46 | · display your valid copyright notice on your programs; and 47 | 48 | · indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your programs. 49 | 50 | iii. Distribution Restrictions. You may not 51 | 52 | · alter any copyright, trademark or patent notice in the Distributable Code; 53 | 54 | · use Microsoft’s trademarks in your programs’ names or in a way that suggests your programs come from or are endorsed by Microsoft; 55 | 56 | · include Distributable Code in malicious, deceptive or unlawful programs; or 57 | 58 | · modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that 59 | 60 | · the code be disclosed or distributed in source code form; or 61 | 62 | · others have the right to modify it. 63 | 64 | 3. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not 65 | 66 | · work around any technical limitations in the software; 67 | 68 | · reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation; 69 | 70 | · publish the software for others to copy; 71 | 72 | · rent, lease or lend the software; 73 | 74 | · transfer the software or this agreement to any third party; or 75 | 76 | · use the software for commercial software hosting services. 77 | 78 | 4. BACKUP COPY. You may make one backup copy of the software. You may use it only to reinstall the software. 79 | 80 | 5. DOCUMENTATION. Any person that has valid access to your computer or internal network may copy and use the documentation for your internal, reference purposes. 81 | 82 | 6. EXPORT RESTRICTIONS. The software is subject to United States export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the software. These laws include restrictions on destinations, end users and end use. For additional information, see www.microsoft.com/exporting. 83 | 84 | 7. SUPPORT SERVICES. Because this software is “as is,” we may not provide support services for it. 85 | 86 | 8. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services. 87 | 88 | 9. APPLICABLE LAW. 89 | 90 | a. United States. If you acquired the software in the United States, Washington state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. The laws of the state where you live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort. 91 | 92 | b. Outside the United States. If you acquired the software in any other country, the laws of that country apply. 93 | 94 | 10. LEGAL EFFECT. This agreement describes certain legal rights. You may have other rights under the laws of your country. You may also have rights with respect to the party from whom you acquired the software. This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so. 95 | 96 | 11. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS-IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS OR STATUTORY GUARANTEES UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 97 | 98 | FOR AUSTRALIA – YOU HAVE STATUTORY GUARANTEES UNDER THE AUSTRALIAN CONSUMER LAW AND NOTHING IN THESE TERMS IS INTENDED TO AFFECT THOSE RIGHTS. 99 | 100 | 12. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. 101 | 102 | This limitation applies to 103 | 104 | · anything related to the software, services, content (including code) on third party Internet sites, or third party programs; and 105 | 106 | · claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law. 107 | 108 | It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages. 109 | 110 | Please note: As this software is distributed in Quebec, Canada, some of the clauses in this agreement are provided below in French. 111 | 112 | Remarque : Ce logiciel étant distribué au Québec, Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français. 113 | 114 | EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel ». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues. 115 | 116 | LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices. 117 | 118 | Cette limitation concerne : 119 | 120 | · tout ce qui est relié au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers ; et 121 | 122 | · les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur. 123 | 124 | Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre égard. 125 | 126 | EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas. 127 | 128 | 129 | -------------------------------------------------------------------------------- /csharp/Torneo/Score.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | /// 5 | /// Provides an abstraction of a score in a tournament. 6 | /// 7 | public abstract class Score : IComparable, IEquatable 8 | { 9 | /// 10 | /// Adds one Score to another yielding their sum. 11 | /// 12 | /// The first addend. 13 | /// The second addend. 14 | /// A new Score representing the sum of the two addends. 15 | public static Score operator +(Score score1, Score score2) 16 | { 17 | if (score1 != null) 18 | { 19 | return score1.Add(score2); 20 | } 21 | 22 | if (score2 != null) 23 | { 24 | return score2.Add(score1); 25 | } 26 | 27 | return null; 28 | } 29 | 30 | /// 31 | /// Determines whether two specified instances of Score are equal. 32 | /// 33 | /// The first score for which to check equality. 34 | /// The second score for which to check equality. 35 | /// true if score2 and score1 represent the same score; otherwise, false. 36 | public static bool operator ==(Score score1, Score score2) 37 | { 38 | if (object.ReferenceEquals(score1, score2)) 39 | { 40 | return true; 41 | } 42 | 43 | if ((object)score1 == null || (object)score2 == null) 44 | { 45 | return false; 46 | } 47 | 48 | return score1.CompareTo(score2) == 0; 49 | } 50 | 51 | /// 52 | /// Determines whether two specified instances of Score are not equal. 53 | /// 54 | /// The first score for which to check inequality. 55 | /// The second score for which to check inequality. 56 | /// true if score2 and score1 represent a different score; otherwise, false. 57 | public static bool operator !=(Score score1, Score score2) 58 | { 59 | if (object.ReferenceEquals(score1, score2)) 60 | { 61 | return false; 62 | } 63 | 64 | if ((object)score1 == null || (object)score2 == null) 65 | { 66 | return true; 67 | } 68 | 69 | return score1.CompareTo(score2) != 0; 70 | } 71 | 72 | /// 73 | /// Determines whether or not one specified Score is better than another specified Score. 74 | /// 75 | /// The first score for which to check inequality. 76 | /// The second score for which to check inequality. 77 | /// true if score1 represent a better score than score2; otherwise, false. 78 | public static bool operator >(Score score1, Score score2) 79 | { 80 | if (object.ReferenceEquals(score1, score2)) 81 | { 82 | return false; 83 | } 84 | 85 | if ((object)score1 != null && (object)score2 == null) 86 | { 87 | return true; 88 | } 89 | 90 | if ((object)score1 == null && (object)score2 != null) 91 | { 92 | return false; 93 | } 94 | 95 | return score1.CompareTo(score2) > 0; 96 | } 97 | 98 | /// 99 | /// Determines whether or not one specified Score is worse than another specified Score. 100 | /// 101 | /// The first score for which to check inequality. 102 | /// The second score for which to check inequality. 103 | /// true if score1 represent a worse score than score2; otherwise, false. 104 | public static bool operator <(Score score1, Score score2) 105 | { 106 | if (object.ReferenceEquals(score1, score2)) 107 | { 108 | return false; 109 | } 110 | 111 | if ((object)score1 != null && (object)score2 == null) 112 | { 113 | return false; 114 | } 115 | 116 | if ((object)score1 == null && (object)score2 != null) 117 | { 118 | return true; 119 | } 120 | 121 | return score1.CompareTo(score2) < 0; 122 | } 123 | 124 | /// 125 | /// Determines whether or not one specified Score is better than or equal to another specified Score. 126 | /// 127 | /// The first score for which to check inequality. 128 | /// The second score for which to check inequality. 129 | /// true if score1 represent a score that is better than or equal to score2; otherwise, false. 130 | public static bool operator >=(Score score1, Score score2) 131 | { 132 | if (object.ReferenceEquals(score1, score2)) 133 | { 134 | return true; 135 | } 136 | 137 | if ((object)score1 != null && (object)score2 == null) 138 | { 139 | return true; 140 | } 141 | 142 | if ((object)score1 == null && (object)score2 != null) 143 | { 144 | return false; 145 | } 146 | 147 | return score1.CompareTo(score2) >= 0; 148 | } 149 | 150 | /// 151 | /// Determines whether or not one specified Score is worse than or equal to another specified Score. 152 | /// 153 | /// The first score for which to check inequality. 154 | /// The second score for which to check inequality. 155 | /// true if score1 represent a score that is worse than or equal to score2; otherwise, false. 156 | public static bool operator <=(Score score1, Score score2) 157 | { 158 | if (object.ReferenceEquals(score1, score2)) 159 | { 160 | return true; 161 | } 162 | 163 | if ((object)score1 != null && (object)score2 == null) 164 | { 165 | return false; 166 | } 167 | 168 | if ((object)score1 == null && (object)score2 != null) 169 | { 170 | return true; 171 | } 172 | 173 | return score1.CompareTo(score2) <= 0; 174 | } 175 | 176 | /// 177 | /// Returns a value indicating whether this instance is equal to the specified Score instance. 178 | /// 179 | /// A Score instance to compare to this instance. 180 | /// true if the value parameter equals the value of this instance; otherwise, false. 181 | public bool Equals(Score other) 182 | { 183 | return this == other; 184 | } 185 | 186 | /// 187 | /// Returns a value indicating whether this instance is equal to the specified object. 188 | /// 189 | /// An object to compare to this instance. 190 | /// true if the value parameter is a Score instance and equals the value of this instance; otherwise, false. 191 | public override bool Equals(object obj) 192 | { 193 | var o = obj as Score; 194 | 195 | if (o == null) 196 | { 197 | return false; 198 | } 199 | 200 | return this.Equals(o); 201 | } 202 | 203 | /// 204 | /// Returns the hash code for this instance. 205 | /// 206 | /// A 32-bit signed integer hash code. 207 | public abstract override int GetHashCode(); 208 | 209 | /// 210 | /// Compares the value of this instance to a specified Score value 211 | /// and returns an integer that indicates whether this instance is better than, 212 | /// the same as, or worse than the specified Score value. 213 | /// 214 | /// A Score object to compare. 215 | /// 216 | /// A signed number indicating the relative values of this instance and the value 217 | /// parameter. Value Description: Less than zero: This instance is worse than 218 | /// value. Zero: This instance is the same as value. Greater than zero: This instance 219 | /// is better than value. 220 | /// 221 | public abstract int CompareTo(Score other); 222 | 223 | /// 224 | /// Adds this instance to the specified score. Used in overloading the '+' operator. 225 | /// 226 | /// The other score to add to this instance. 227 | /// A new instance of Score representing the sum of this instance and the addend. 228 | public abstract Score Add(Score addend); 229 | } 230 | 231 | public sealed class HighestPointsScore : Score 232 | { 233 | /// 234 | /// Initializes a new instance of the HighestPointsScore class with the specified number of points. 235 | /// 236 | /// The number of points that the new instance will represent. 237 | public HighestPointsScore(double points) 238 | { 239 | this.Points = points; 240 | } 241 | 242 | /// 243 | /// Gets the number of points that this score represents. 244 | /// 245 | public double Points 246 | { 247 | get; 248 | private set; 249 | } 250 | 251 | /// 252 | /// Converts the points value of this instance to its equivalent string representation. 253 | /// 254 | /// The string representation of the value of this instance. 255 | public override string ToString() 256 | { 257 | return this.Points.ToString(CultureInfo.InvariantCulture); 258 | } 259 | 260 | /// 261 | /// Returns the hash code for this instance. 262 | /// 263 | /// A 32-bit signed integer hash code. 264 | public override int GetHashCode() 265 | { 266 | return (int)this.Points; 267 | } 268 | 269 | /// 270 | /// Compares the value of this instance to a specified Score value 271 | /// and returns an integer that indicates whether this instance is better than, 272 | /// the same as, or worse than the specified Score value. 273 | /// 274 | /// A Score object to compare. 275 | /// 276 | /// A signed number indicating the relative values of this instance and the value 277 | /// parameter. Value Description: Less than zero: This instance is worse than 278 | /// value. Zero: This instance is the same as value. Greater than zero: This instance 279 | /// is better than value. 280 | /// 281 | public override int CompareTo(Score other) 282 | { 283 | var o = other as HighestPointsScore; 284 | 285 | if (o == null) 286 | { 287 | throw new InvalidOperationException(); 288 | } 289 | 290 | return this.Points.CompareTo(o.Points); 291 | } 292 | 293 | /// 294 | /// Adds this instance to the specified score. Used in overloading the '+' operator. 295 | /// 296 | /// The other score to add to this instance. 297 | /// A new instance of Score representing the sum of this instance and the addend. 298 | public override Score Add(Score addend) 299 | { 300 | if (addend == null) 301 | { 302 | return new HighestPointsScore(this.Points); 303 | } 304 | 305 | var a = addend as HighestPointsScore; 306 | 307 | if (a == null) 308 | { 309 | throw new InvalidOperationException(); 310 | } 311 | 312 | return new HighestPointsScore(this.Points + a.Points); 313 | } 314 | } 315 | --------------------------------------------------------------------------------