Git Product home page Git Product logo

r2wars's Introduction

r2wars

Alt text

The C# implementation of the r2wars tournament competition

Tournament api from: https://github.com/otac0n/tournaments

Description

r2wars is a game similar to corewars, where 2 programs run on a shared memory space trying to catch each other in order to trash their code and make them crash.

This game was initially developed by pancake as a PoC in here

You can refer to the r2wars For N00bs talk from r2con2020 for more information:

Furthermore, you can find an explanation of the game in the first competition that happened during the 2nd r2con in 2017.

This repository contains an evolved implementation of the engine written in C# by SkUaTeR dropping the MFC requirement that was making it impossible to run outside Windows.

The solution was to use an embedded webserver that provides a web interface using websockets to stream the process changes from the M

Dependencies

  • Mono / .NET Runtime (always from mono project some distros packages dont work)
  • radare2

On windows you need to have radare2.exe and rasm2.exe in the same directory as the r2wars.exe executable.

On Mac/Linux/BSD, r2wars will try to find them in the PATH.

--pancake

r2wars's People

Contributors

captnbanana avatar crclark96 avatar florianhofhammer avatar hmht avatar janniskirschner avatar ps1337 avatar radare avatar sanguinawer avatar trufae avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

r2wars's Issues

Version Detection on Debian/Mono

public static bool IsWindows() =>
RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

returns true on Debian 4.9 + Mono 4.6.2 (from apt) thus providing false version detection.

Unable to start tournament

Hello,
When I press start after loading 2 x86 warriors (the ones in the examples) the web interface does nothing.
I only see this on the console:

r2path =  radare2.exe
RES = NOK

I am running Ubuntu 18.04. Is there any way to give you more information about this?

Battle hangs unexpectedly

Environment

I'm running a Debian-based GNU/Linux distribution and installed Mono according to the instructions at https://www.mono-project.com/download/stable/.

The output of mono --version can be found below:

Mono JIT compiler version 6.12.0.122 (tarball Mon Feb 22 17:33:28 UTC 2021)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug 
        Interpreter:   yes
        LLVM:          yes(610)
        Suspend:       hybrid
        GC:            sgen (concurrent by default)

Description

While experimenting with some of the contestants from the previous r2con, I've noticed a weird behavior - every now and then a battle hangs.

I've not been able to find the root cause, but noticed the following output in the terminal when I press ENTER (regardless of whether or not the battle has hanged):

9/19/2021 3:11:04 PM|Fatal|WebSocketServer.receiveRequest|System.Threading.ThreadAbortException: Thread was being aborted.
                             at (wrapper managed-to-native) System.Net.Sockets.Socket.Accept_icall(intptr,int&,bool)
                             at System.Net.Sockets.Socket.Accept_internal (System.Net.Sockets.SafeSocketHandle safeHandle, System.Int32& error, System.Boolean blocking) [0x0000c] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0 
                             at System.Net.Sockets.Socket.Accept () [0x00008] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0 
                             at System.Net.Sockets.TcpListener.AcceptTcpClient () [0x0001e] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0 
                             at WebSocketSharp.Server.WebSocketServer.receiveRequest () [0x00012] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 

Tried compiling the latest version of websocket-sharp and use it, but the issue remains.

Test

It's not clear to me yet how this can be reproduced 100% but I've been able to trigger this somehow by running a tournament with the bots from examples/r2con2020/round1/, and soo.x86-32.asm seems like a good candidate for this.

docker makefile invokes start.sh script using incompatible shell

As illustrated below, the makefile invokes start.sh using the sh shell, instead of bash (as specified on the first line of start.sh).

Since sh does not support array references (or the &> operator), this causes the build rule to fail since start.sh does not execute correctly.

Build succeeded.
         0 Warning(s)
         0 Error(s)

Time Elapsed 00:00:01.4796570
Removing intermediate container f3ce5efb6766
 ---> 26d304e2abc2
Step 9/10 : WORKDIR /opt/r2wars/csharp/bin/Release
 ---> Running in fc9ddc921d43
Removing intermediate container fc9ddc921d43
 ---> c5b79ce085cc
Step 10/10 : ENTRYPOINT ["mono", "r2wars.exe"]
 ---> Running in 7390798642c1
Removing intermediate container 7390798642c1
 ---> cdaac7928832
Successfully built cdaac7928832
Successfully tagged r2wars:latest
sh start.sh
start.sh: 4: start.sh: Bad substitution
docker: invalid reference format.
See 'docker run --help'.
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 125

r2wars/docker on  master on v20.10.17 took 3m 21s
➜ docker --version
Docker version 20.10.17, build 100c701

r2wars/docker on  master on v20.10.17
➜ make
docker images | grep -q ^r2wars || docker build --no-cache -t r2wars .
sh start.sh
start.sh: 4: start.sh: Bad substitution
docker: invalid reference format.
See 'docker run --help'.
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 125

r2wars/docker on  master on v20.10.17
➜ shellcheck -s sh start.sh

In start.sh line 4:
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
                        ^-- SC2039: In POSIX sh, array references are undefined.
                                              ^-- SC2039: In POSIX sh, &> is undefined.


In start.sh line 6:
docker run --rm -it -p 9664:9664 -p 9966:9966 --name r2wars -v $DIR/warriors:/opt/r2wars/csharp/bin/Release/warriors r2wars
                                                               ^-- SC2086: Double quote to prevent globbing and word splitting.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.