Skip to content

Commit

Permalink
Update HFP.go
Browse files Browse the repository at this point in the history
Critical update for saving to file leackage
  • Loading branch information
ivlovric authored May 11, 2023
1 parent 3671a07 commit ca3fa97
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions HFP.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"time"
)

const AppVersion = "0.54"
const AppVersion = "0.55"

var localAddr *string = flag.String("l", ":9060", "Local HEP listening address")
var remoteAddr *string = flag.String("r", "192.168.2.2:9060", "Remote HEP address")
Expand Down Expand Up @@ -68,16 +68,15 @@ func initLoopbackConn(wg *sync.WaitGroup) {

}

func copyHEPbufftoFile(inbytes []byte, file string) (int64, error) {
func copyHEPbufftoFile(inbytes *net.TCPConn, file string) (int64, error) {

destination, err := os.OpenFile(file, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
fmt.Println("Open HEP file error", err)
}

defer destination.Close()
nBytes, err := destination.Write(inbytes)

nBytes, err := io.Copy(destination, inbytes)
if err != nil {
log.Println("||-->X File Send HEP from buffer to file error", err)
} else {
Expand Down Expand Up @@ -168,7 +167,7 @@ func proxyConn(conn *net.TCPConn) {
for _, ipf := range filterIPs {
if ((hepPkt.SrcIP == string(ipf) || hepPkt.DstIP == string(ipf)) && *IPfilter != "" && *IPfilterAction == "pass") || (*IPfilter == "" || (hepPkt.SrcIP != string(ipf) || hepPkt.DstIP != string(ipf)) && *IPfilter != "" && *IPfilterAction == "reject") {

go copyHEPbufftoFile(buf[:data], HEPsavefile)
go copyHEPbufftoFile(conn, HEPsavefile)
}
}

Expand Down Expand Up @@ -237,7 +236,7 @@ func proxyConn(conn *net.TCPConn) {
if _, err_HEPout := fmt.Fprint(rConn, string(buf[:data])); err_HEPout != nil {
log.Println("||--> Sending HEP OUT error:", err_HEPout)
// rb := bytes.NewReader(buf[:data])
go copyHEPbufftoFile(buf[:data], HEPsavefile)
go copyHEPbufftoFile(conn, HEPsavefile)
accepted = true
return
} else {
Expand Down Expand Up @@ -289,7 +288,7 @@ func proxyConn(conn *net.TCPConn) {
if _, err_HEPout := fmt.Fprint(rConn, string(buf[:data])); err_HEPout != nil {
log.Println("||--> Sending HEP OUT error:", err_HEPout)
//rb := bytes.NewReader(buf[:data])
go copyHEPbufftoFile(buf[:data], HEPsavefile)
go copyHEPbufftoFile(conn, HEPsavefile)
return
} else {
if *Debug == "on" {
Expand All @@ -303,7 +302,7 @@ func proxyConn(conn *net.TCPConn) {
if _, err_HEPout := fmt.Fprint(rConn, string(buf[:data])); err_HEPout != nil {
log.Println("||--> Sending HEP OUT error:", err_HEPout)
// rb := bytes.NewReader(buf[:data])
go copyHEPbufftoFile(buf[:data], HEPsavefile)
go copyHEPbufftoFile(conn, HEPsavefile)
return
} else {
if *Debug == "on" {
Expand Down

0 comments on commit ca3fa97

Please sign in to comment.