Projects STRLCPY goc2 Commits adcf6ad8
🤬
  • ■ ■ ■ ■ ■ ■
    pkg/cli/cli.go
    skipped 147 lines
    148 148   if agent != "Not Connected" {
    149 149   wd, err := getAgentWorking(c2 + "/api/agent/" + agent)
    150 150   if err != nil {
    151  - fmt.Println(err)
     151 + fmt.Println("Agent does not exist.")
    152 152   agent = "Not Connected"
    153 153   l.SetPrompt(" <" + blue(agent) + "*> ")
    154 154   } else {
    skipped 18 lines
    173 173   switch {
    174 174   case strings.HasPrefix(line, "agent "):
    175 175   parts := strings.Split(line, " ")
    176  - agent = parts[1]
     176 + if len(parts) == 2 {
     177 + agent = parts[1]
     178 + } else {
     179 + agent = "Not Connected"
     180 + }
    177 181   case line == "login":
    178 182   pswd, err := l.ReadPassword("please enter your password: ")
    179 183   if err != nil {
    skipped 13 lines
    193 197   time.Sleep(4 * time.Second)
    194 198   case line == "":
    195 199   default:
     200 + if agent == "Not Connected" {
     201 + fmt.Println("You are not connected to an agent.")
     202 + break
     203 + }
    196 204   cmdString := line
    197 205   if cmdString == "exit" {
    198 206   os.Exit(1)
    199 207   }
    200 208   
    201 209   if strings.Contains(cmdString, "upload ") {
    202  - //uuid := shortuuid.New()
    203 210   parts := strings.Split(cmdString, " ")
    204 211   file := parts[1]
    205  - //copy(file, "/tmp/"+uuid)
    206 212   tempfile := uploadFile(file, c2)
    207 213   if tempfile == "NotFound" {
    208 214   fmt.Println("File not found")
    skipped 324 lines
Please wait...
Page is in error, reload to recover