Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

uniqueginun's avatar

control operating systems remotely with PHP

Hello <>

I want to create a tool like this one https://github.com/tiagorlampert/CHAOS in PHP and basically what it does is generate a binary file ".exe" and when you run that file in a device you can now through a web interface run some OS-Related commands on that device.

first: you can from this GUI generate a binary for a specific device.

and when it creates the binary for that device you will see it in the "connected devices" section as below:

and from the actions menu you can run some OS commands like php --version

so, is there any tool like this written in PHP I can take a look at? or what topics I need to read about and understand to create something like this? this one written in golang

0 likes
10 replies
skeith22's avatar

This is fairly simple, you could run command on any OS with shell_exec function,

for example you have a POST route that would receive a string command like php -v

in your YourOwnController@whateverMethodName you can have this

public function whateverMethodName(Request $request)
{
    $output = shell_exec('php -v');
    return "<pre>$output</pre>";
}

With this idea you can expand to whatever you wanna happen.

cheers.

uniqueginun's avatar

@skeith22

But I should be able to run commands on a remote operating system. The above code will run this command on my own server. the idea is to generate a binary that will open a connection with my website and allow me to run operating system commands on that device.

Snapey's avatar

The standard way to run commands on a remote server is with SSH. Is there any reason why you don't want this?

uniqueginun's avatar

@Snapey

in our work, we sometimes need to go to our client's offices and open their PC and run some operating system commands to gather some information. what we need is to generate a binary that we will give to our customer to execute it on his device like a windows PC which will open a connection between our website and his device and allow us to run operating system commands on that device.

Snapey's avatar
Snapey
Best Answer
Level 122

@uniqueginun So use an off the shelf solution live team view. Don't hack your own backdoor because sooner or later it will be broken into and your client systems exposed - and it will be your fault.

martinbean's avatar

@uniqueginun Why not use that GitHub repository if it does what you want?

PHP is a web scripting language. It’s not suitable for creating binaries. At all. Use the appropriate tool for each job. If you want to build a binary, use an actual systems programming language like C/C++ or Go.

martinbean's avatar

@uniqueginun Why does that matter if it’s a compiled executable?

I don‘t work with Cocoa, Objective-C, or Swift but it doesn’t stop me using macOS applications written in it.

uniqueginun's avatar

@martinbean what I meant is that we will need to support that product. add features in the future fix bugs and so on. and we can't hire golang developer. so we want to build the whole thing in php again

zoidq's avatar

Perhaps what you're looking for is a reverse shell written in php along the same lines as this: https://github.com/pentestmonkey/php-reverse-shell ?

Over all, as others have suggested it sounds like there would be much more suitable off the shelf technologies to choose from for reasons including:

  • PHP is primary a web language
  • You would need to create a win32 script to download a php.exe binary and your script
  • There are significant security implications that are likely to breach company policies

Good luck!

Please or to participate in this conversation.