Made padding size random [max/2, max); use of improved goutmp host lookup

This commit is contained in:
Russ Magee 2018-10-02 11:03:10 -07:00
parent 1485e8392e
commit 103070d00a
2 changed files with 9 additions and 12 deletions

View file

@ -590,8 +590,9 @@ func (hc *Conn) WritePacket(b []byte, op byte) (n int, err error) {
} }
//Padding //Padding
padLen := PAD_SZ - ((uint32(len(b)) + PAD_SZ) % PAD_SZ) padSz := (rand.Intn(PAD_SZ) / 2) + (PAD_SZ / 2)
if padLen == PAD_SZ { padLen := padSz - ((len(b) + padSz) % padSz)
if padLen == padSz {
// No padding required // No padding required
padLen = 0 padLen = 0
} }

View file

@ -22,7 +22,6 @@ import (
"os/exec" "os/exec"
"os/user" "os/user"
"path" "path"
"strings"
"sync" "sync"
"syscall" "syscall"
@ -510,7 +509,7 @@ func main() {
if rec.Op()[0] == 'A' { if rec.Op()[0] == 'A' {
// Generate automated login token // Generate automated login token
addr := hc.RemoteAddr() addr := hc.RemoteAddr()
hname := strings.Split(addr.String(), ":")[0] hname := goutmp.GetHost(addr.String())
log.Printf("[Generating autologin token for [%s@%s]]\n", rec.Who(), hname) log.Printf("[Generating autologin token for [%s@%s]]\n", rec.Who(), hname)
token := GenAuthToken(string(rec.Who()), string(rec.ConnHost())) token := GenAuthToken(string(rec.Who()), string(rec.ConnHost()))
tokenCmd := fmt.Sprintf("echo \"%s\" | tee -a ~/.hkexsh_id", token) tokenCmd := fmt.Sprintf("echo \"%s\" | tee -a ~/.hkexsh_id", token)
@ -527,9 +526,7 @@ func main() {
} else if rec.Op()[0] == 'c' { } else if rec.Op()[0] == 'c' {
// Non-interactive command // Non-interactive command
addr := hc.RemoteAddr() addr := hc.RemoteAddr()
//hname := goutmp.GetHost(addr.String()) hname := goutmp.GetHost(addr.String())
hname := strings.Split(addr.String(), ":")[0]
log.Printf("[Running command for [%s@%s]]\n", rec.Who(), hname) log.Printf("[Running command for [%s@%s]]\n", rec.Who(), hname)
runErr, cmdStatus := runShellAs(string(rec.Who()), string(rec.TermType()), string(rec.Cmd()), false, hc, chaffEnabled) runErr, cmdStatus := runShellAs(string(rec.Who()), string(rec.TermType()), string(rec.Cmd()), false, hc, chaffEnabled)
// Returned hopefully via an EOF or exit/logout; // Returned hopefully via an EOF or exit/logout;
@ -544,8 +541,7 @@ func main() {
} else if rec.Op()[0] == 's' { } else if rec.Op()[0] == 's' {
// Interactive session // Interactive session
addr := hc.RemoteAddr() addr := hc.RemoteAddr()
//hname := goutmp.GetHost(addr.String()) hname := goutmp.GetHost(addr.String())
hname := strings.Split(addr.String(), ":")[0]
log.Printf("[Running shell for [%s@%s]]\n", rec.Who(), hname) log.Printf("[Running shell for [%s@%s]]\n", rec.Who(), hname)
utmpx := goutmp.Put_utmp(string(rec.Who()), hname) utmpx := goutmp.Put_utmp(string(rec.Who()), hname)
@ -565,7 +561,7 @@ func main() {
// File copy (destination) operation - client copy to server // File copy (destination) operation - client copy to server
log.Printf("[Client->Server copy]\n") log.Printf("[Client->Server copy]\n")
addr := hc.RemoteAddr() addr := hc.RemoteAddr()
hname := strings.Split(addr.String(), ":")[0] hname := goutmp.GetHost(addr.String())
log.Printf("[Running copy for [%s@%s]]\n", rec.Who(), hname) log.Printf("[Running copy for [%s@%s]]\n", rec.Who(), hname)
runErr, cmdStatus := runClientToServerCopyAs(string(rec.Who()), string(rec.TermType()), hc, string(rec.Cmd()), chaffEnabled) runErr, cmdStatus := runClientToServerCopyAs(string(rec.Who()), string(rec.TermType()), hc, string(rec.Cmd()), chaffEnabled)
// Returned hopefully via an EOF or exit/logout; // Returned hopefully via an EOF or exit/logout;
@ -587,7 +583,7 @@ func main() {
// File copy (src) operation - server copy to client // File copy (src) operation - server copy to client
log.Printf("[Server->Client copy]\n") log.Printf("[Server->Client copy]\n")
addr := hc.RemoteAddr() addr := hc.RemoteAddr()
hname := strings.Split(addr.String(), ":")[0] hname := goutmp.GetHost(addr.String())
log.Printf("[Running copy for [%s@%s]]\n", rec.Who(), hname) log.Printf("[Running copy for [%s@%s]]\n", rec.Who(), hname)
runErr, cmdStatus := runServerToClientCopyAs(string(rec.Who()), string(rec.TermType()), hc, string(rec.Cmd()), chaffEnabled) runErr, cmdStatus := runServerToClientCopyAs(string(rec.Who()), string(rec.TermType()), hc, string(rec.Cmd()), chaffEnabled)
// Returned hopefully via an EOF or exit/logout; // Returned hopefully via an EOF or exit/logout;