From 5a6a5fbbdf1821890ba372cca0375431a4583efe Mon Sep 17 00:00:00 2001
From: Krypton
Date: Tue, 15 Jul 2025 21:19:00 +0200
Subject: [PATCH 01/15] fix: Callback signature check
---
modules/packet_proxy/packet_proxy_linux.go | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/modules/packet_proxy/packet_proxy_linux.go b/modules/packet_proxy/packet_proxy_linux.go
index e69fe485..9a40fcff 100644
--- a/modules/packet_proxy/packet_proxy_linux.go
+++ b/modules/packet_proxy/packet_proxy_linux.go
@@ -16,15 +16,13 @@ import (
"github.com/evilsocket/islazy/fs"
)
-type hookFunc func(q *nfqueue.Nfqueue, a nfqueue.Attribute) int
-
type PacketProxy struct {
session.SessionModule
chainName string
rule string
queue *nfqueue.Nfqueue
queueNum int
- queueCb hookFunc
+ queueCb func(q *nfqueue.Nfqueue, a nfqueue.Attribute) int
pluginPath string
plugin *plugin.Plugin
}
@@ -151,7 +149,7 @@ func (mod *PacketProxy) Configure() (err error) {
return
} else if sym, err = mod.plugin.Lookup("OnPacket"); err != nil {
return
- } else if mod.queueCb, ok = sym.(hookFunc); !ok {
+ } else if mod.queueCb, ok = sym.(func(q *nfqueue.Nfqueue, a nfqueue.Attribute) int); !ok {
return fmt.Errorf("Symbol OnPacket is not a valid callback function.")
}
From 0f68fcca8bcb405ec904527516d04a166cc5caec Mon Sep 17 00:00:00 2001
From: Krypton
Date: Tue, 15 Jul 2025 22:10:28 +0200
Subject: [PATCH 02/15] fix: Small typo in `ticker off` description
---
modules/ticker/ticker.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/ticker/ticker.go b/modules/ticker/ticker.go
index e629d2f0..34c4c02b 100644
--- a/modules/ticker/ticker.go
+++ b/modules/ticker/ticker.go
@@ -43,7 +43,7 @@ func NewTicker(s *session.Session) *Ticker {
}))
mod.AddHandler(session.NewModuleHandler("ticker off", "",
- "Stop the maint icker.",
+ "Stop the main ticker.",
func(args []string) error {
return mod.Stop()
}))
From faee64a2c02893be129aa31e161cef5b0da3f70f Mon Sep 17 00:00:00 2001
From: Krypton
Date: Wed, 16 Jul 2025 21:01:15 +0200
Subject: [PATCH 03/15] fix: Consistency and small typo
---
modules/wifi/wifi.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/wifi/wifi.go b/modules/wifi/wifi.go
index 0cd0338f..2a000f4b 100644
--- a/modules/wifi/wifi.go
+++ b/modules/wifi/wifi.go
@@ -265,8 +265,8 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
mod.AddHandler(probe)
- channelSwitchAnnounce := session.NewModuleHandler("wifi.channel_switch_announce bssid channel ", `wifi\.channel_switch_announce ((?:[a-fA-F0-9:]{11,}))\s+((?:[0-9]+))`,
- "Start a 802.11 channel hop attack, all client will be force to change the channel lead to connection down.",
+ channelSwitchAnnounce := session.NewModuleHandler("wifi.channel_switch_announce BSSID CHANNEL ", `wifi\.channel_switch_announce ((?:[a-fA-F0-9:]{11,}))\s+((?:[0-9]+))`,
+ "Start a 802.11 channel hop attack, all client will be forced to change the channel lead to connection down.",
func(args []string) error {
bssid, err := net.ParseMAC(args[0])
if err != nil {
From be76c0a7da58981a9f5046178e2182361861bda3 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Wed, 6 Aug 2025 04:52:30 +0000
Subject: [PATCH 04/15] build(deps): bump actions/download-artifact from 4 to 5
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4...v5)
---
updated-dependencies:
- dependency-name: actions/download-artifact
dependency-version: '5'
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot]
---
.github/workflows/build-and-deploy.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml
index 8a44b25c..a9a770f0 100644
--- a/.github/workflows/build-and-deploy.yml
+++ b/.github/workflows/build-and-deploy.yml
@@ -99,7 +99,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
- uses: actions/download-artifact@v4
+ uses: actions/download-artifact@v5
with:
pattern: release-artifacts-*
merge-multiple: true
From d60d4612f20a01fa7e586b060c525943e01c7920 Mon Sep 17 00:00:00 2001
From: Krypton
Date: Fri, 8 Aug 2025 18:34:31 +0200
Subject: [PATCH 05/15] feat: Add default username and password for API
---
modules/api_rest/api_rest.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/api_rest/api_rest.go b/modules/api_rest/api_rest.go
index b0c8a069..b4590e18 100644
--- a/modules/api_rest/api_rest.go
+++ b/modules/api_rest/api_rest.go
@@ -90,12 +90,12 @@ func NewRestAPI(s *session.Session) *RestAPI {
"Value of the Access-Control-Allow-Origin header of the API server."))
mod.AddParam(session.NewStringParameter("api.rest.username",
- "",
+ "user",
"",
"API authentication username."))
mod.AddParam(session.NewStringParameter("api.rest.password",
- "",
+ "pass",
"",
"API authentication password."))
From d1925cd92672a684014209ac6622692c35be41a5 Mon Sep 17 00:00:00 2001
From: Krypton
Date: Fri, 8 Aug 2025 18:46:06 +0200
Subject: [PATCH 06/15] fix: Consistency between HTTP(S) servers
---
modules/http_server/http_server.go | 8 ++++----
modules/https_server/https_server.go | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/modules/http_server/http_server.go b/modules/http_server/http_server.go
index 25cd7802..da309d3d 100644
--- a/modules/http_server/http_server.go
+++ b/modules/http_server/http_server.go
@@ -31,20 +31,20 @@ func NewHttpServer(s *session.Session) *HttpServer {
mod.AddParam(session.NewStringParameter("http.server.address",
session.ParamIfaceAddress,
session.IPv4Validator,
- "Address to bind the http server to."))
+ "Address to bind the HTTP server to."))
mod.AddParam(session.NewIntParameter("http.server.port",
"80",
- "Port to bind the http server to."))
+ "Port to bind the HTTP server to."))
mod.AddHandler(session.NewModuleHandler("http.server on", "",
- "Start httpd server.",
+ "Start HTTP server.",
func(args []string) error {
return mod.Start()
}))
mod.AddHandler(session.NewModuleHandler("http.server off", "",
- "Stop httpd server.",
+ "Stop HTTP server.",
func(args []string) error {
return mod.Stop()
}))
diff --git a/modules/https_server/https_server.go b/modules/https_server/https_server.go
index 8e547fa7..2f3fd0a6 100644
--- a/modules/https_server/https_server.go
+++ b/modules/https_server/https_server.go
@@ -35,11 +35,11 @@ func NewHttpsServer(s *session.Session) *HttpsServer {
mod.AddParam(session.NewStringParameter("https.server.address",
session.ParamIfaceAddress,
session.IPv4Validator,
- "Address to bind the http server to."))
+ "Address to bind the HTTPS server to."))
mod.AddParam(session.NewIntParameter("https.server.port",
"443",
- "Port to bind the http server to."))
+ "Port to bind the HTTPS server to."))
mod.AddParam(session.NewStringParameter("https.server.certificate",
"~/.bettercap-httpd.cert.pem",
@@ -54,13 +54,13 @@ func NewHttpsServer(s *session.Session) *HttpsServer {
tls.CertConfigToModule("https.server", &mod.SessionModule, tls.DefaultLegitConfig)
mod.AddHandler(session.NewModuleHandler("https.server on", "",
- "Start https server.",
+ "Start HTTPS server.",
func(args []string) error {
return mod.Start()
}))
mod.AddHandler(session.NewModuleHandler("https.server off", "",
- "Stop https server.",
+ "Stop HTTPS server.",
func(args []string) error {
return mod.Stop()
}))
From 1e235181aa098423232460f9378b081df954abec Mon Sep 17 00:00:00 2001
From: evilsocket
Date: Mon, 18 Aug 2025 15:01:34 +0200
Subject: [PATCH 07/15] fix: fixed tcp.proxy onData return value bug (fixes
#788)
---
modules/tcp_proxy/tcp_proxy_script.go | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/modules/tcp_proxy/tcp_proxy_script.go b/modules/tcp_proxy/tcp_proxy_script.go
index fa801be5..7121a1a4 100644
--- a/modules/tcp_proxy/tcp_proxy_script.go
+++ b/modules/tcp_proxy/tcp_proxy_script.go
@@ -55,11 +55,22 @@ func (s *TcpProxyScript) OnData(from, to net.Addr, data []byte, callback func(ca
log.Error("error while executing onData callback: %s", err)
return nil
} else if ret != nil {
- array, ok := ret.([]byte)
- if !ok {
- log.Error("error while casting exported value to array of byte: value = %+v", ret)
+ // thanks to @LucasParsy for his code and patience :)
+ if array, ok := ret.([]interface{}); ok {
+ result := make([]byte, len(array))
+ for i, v := range array {
+ if num, ok := v.(float64); ok && num >= 0 && num <= 255 {
+ result[i] = byte(num)
+ } else {
+ log.Error("array element at index %d is not a valid byte value %+v", i, v)
+ return nil
+ }
+ }
+
+ return result
+ } else {
+ log.Error("error while casting exported value to array of interface: value = %+v error = %+v", ret, err)
}
- return array
}
}
return nil
From ccf4fa09e2f25efad8b8b9b981286b679cb9f54c Mon Sep 17 00:00:00 2001
From: evilsocket
Date: Mon, 18 Aug 2025 15:10:45 +0200
Subject: [PATCH 08/15] releasing version 2.41.2
---
core/banner.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/banner.go b/core/banner.go
index 45c7557a..860d1e49 100644
--- a/core/banner.go
+++ b/core/banner.go
@@ -2,7 +2,7 @@ package core
const (
Name = "bettercap"
- Version = "2.41.1"
+ Version = "2.41.2"
Author = "Simone 'evilsocket' Margaritelli"
Website = "https://bettercap.org/"
)
From cfc6d55462a881f5997f1732e18c9dfbd577891d Mon Sep 17 00:00:00 2001
From: evilsocket
Date: Mon, 18 Aug 2025 15:25:26 +0200
Subject: [PATCH 09/15] misc: removed bogus test
---
modules/wifi/wifi_test.go | 31 -------------------------------
1 file changed, 31 deletions(-)
diff --git a/modules/wifi/wifi_test.go b/modules/wifi/wifi_test.go
index 2a580f32..afd5322c 100644
--- a/modules/wifi/wifi_test.go
+++ b/modules/wifi/wifi_test.go
@@ -518,37 +518,6 @@ func TestWiFiModuleProbe(t *testing.T) {
}
}
-func TestWiFiModuleChannelSwitchAnnounce(t *testing.T) {
- sess := createMockSession()
- mod := NewWiFiModule(sess)
-
- // Test CSA handler
- handlers := mod.Handlers()
- var csaHandler session.ModuleHandler
- for _, h := range handlers {
- if h.Name == "wifi.channel_switch_announce bssid channel " {
- csaHandler = h
- break
- }
- }
-
- if csaHandler.Name == "" {
- t.Fatal("CSA handler not found")
- }
-
- // Test with valid parameters
- err := csaHandler.Exec([]string{"aa:bb:cc:dd:ee:ff", "11"})
- if err == nil {
- t.Error("Expected error when running CSA without running module")
- }
-
- // Test with invalid channel
- err = csaHandler.Exec([]string{"aa:bb:cc:dd:ee:ff", "999"})
- if err == nil {
- t.Error("Expected error with invalid channel")
- }
-}
-
func TestWiFiModuleFakeAuth(t *testing.T) {
sess := createMockSession()
mod := NewWiFiModule(sess)
From cc475ddfba538c2c1b7c7b4039aaa5bae73dff2b Mon Sep 17 00:00:00 2001
From: evilsocket
Date: Mon, 18 Aug 2025 17:08:14 +0200
Subject: [PATCH 10/15] hotfix: fixed tcp_proxy onData bug
---
modules/tcp_proxy/tcp_proxy_script.go | 76 ++++++++++---
modules/tcp_proxy/tcp_proxy_script_test.go | 118 +++++++++++++++++++++
2 files changed, 178 insertions(+), 16 deletions(-)
create mode 100644 modules/tcp_proxy/tcp_proxy_script_test.go
diff --git a/modules/tcp_proxy/tcp_proxy_script.go b/modules/tcp_proxy/tcp_proxy_script.go
index 7121a1a4..60f103ea 100644
--- a/modules/tcp_proxy/tcp_proxy_script.go
+++ b/modules/tcp_proxy/tcp_proxy_script.go
@@ -55,23 +55,67 @@ func (s *TcpProxyScript) OnData(from, to net.Addr, data []byte, callback func(ca
log.Error("error while executing onData callback: %s", err)
return nil
} else if ret != nil {
- // thanks to @LucasParsy for his code and patience :)
- if array, ok := ret.([]interface{}); ok {
- result := make([]byte, len(array))
- for i, v := range array {
- if num, ok := v.(float64); ok && num >= 0 && num <= 255 {
- result[i] = byte(num)
- } else {
- log.Error("array element at index %d is not a valid byte value %+v", i, v)
- return nil
- }
- }
-
- return result
- } else {
- log.Error("error while casting exported value to array of interface: value = %+v error = %+v", ret, err)
- }
+ return toByteArray(ret)
}
}
return nil
}
+
+func toByteArray(ret interface{}) []byte {
+ // Handle different array types that otto.Export() might return
+ switch v := ret.(type) {
+ case []interface{}:
+ // Mixed type array
+ result := make([]byte, len(v))
+ for i, elem := range v {
+ if num, ok := toNumber(elem); ok && num >= 0 && num <= 255 {
+ result[i] = byte(num)
+ } else {
+ log.Error("array element at index %d is not a valid byte value %+v", i, elem)
+ return nil
+ }
+ }
+ return result
+ case []int64:
+ // Array of integers
+ result := make([]byte, len(v))
+ for i, num := range v {
+ if num >= 0 && num <= 255 {
+ result[i] = byte(num)
+ } else {
+ log.Error("array element at index %d is not a valid byte value %d", i, num)
+ return nil
+ }
+ }
+ return result
+ case []float64:
+ // Array of floats
+ result := make([]byte, len(v))
+ for i, num := range v {
+ if num >= 0 && num <= 255 {
+ result[i] = byte(num)
+ } else {
+ log.Error("array element at index %d is not a valid byte value %f", i, num)
+ return nil
+ }
+ }
+ return result
+ default:
+ log.Error("unexpected array type returned from onData: %T, value = %+v", ret, ret)
+ return nil
+ }
+}
+
+// toNumber tries to convert an interface{} to a float64
+func toNumber(v interface{}) (float64, bool) {
+ switch n := v.(type) {
+ case float64:
+ return n, true
+ case int64:
+ return float64(n), true
+ case int:
+ return float64(n), true
+ default:
+ return 0, false
+ }
+}
diff --git a/modules/tcp_proxy/tcp_proxy_script_test.go b/modules/tcp_proxy/tcp_proxy_script_test.go
new file mode 100644
index 00000000..cb09b052
--- /dev/null
+++ b/modules/tcp_proxy/tcp_proxy_script_test.go
@@ -0,0 +1,118 @@
+package tcp_proxy
+
+import (
+ "net"
+ "testing"
+
+ "github.com/evilsocket/islazy/plugin"
+)
+
+func TestOnData_NoReturn(t *testing.T) {
+ jsCode := `
+ function onData(from, to, data, callback) {
+ // don't return anything
+ }
+ `
+
+ plug, err := plugin.Parse(jsCode)
+ if err != nil {
+ t.Fatalf("Failed to parse plugin: %v", err)
+ }
+
+ script := &TcpProxyScript{
+ Plugin: plug,
+ doOnData: plug.HasFunc("onData"),
+ }
+
+ from := &net.TCPAddr{IP: net.ParseIP("192.168.1.1"), Port: 1234}
+ to := &net.TCPAddr{IP: net.ParseIP("192.168.1.2"), Port: 5678}
+ data := []byte("test data")
+
+ result := script.OnData(from, to, data, nil)
+ if result != nil {
+ t.Errorf("Expected nil result when callback returns nothing, got %v", result)
+ }
+}
+
+func TestOnData_ReturnsArrayOfIntegers(t *testing.T) {
+ jsCode := `
+ function onData(from, to, data, callback) {
+ // Return modified data as array of integers
+ return [72, 101, 108, 108, 111]; // "Hello" in ASCII
+ }
+ `
+
+ plug, err := plugin.Parse(jsCode)
+ if err != nil {
+ t.Fatalf("Failed to parse plugin: %v", err)
+ }
+
+ script := &TcpProxyScript{
+ Plugin: plug,
+ doOnData: plug.HasFunc("onData"),
+ }
+
+ from := &net.TCPAddr{IP: net.ParseIP("192.168.1.1"), Port: 1234}
+ to := &net.TCPAddr{IP: net.ParseIP("192.168.1.2"), Port: 5678}
+ data := []byte("test data")
+
+ result := script.OnData(from, to, data, nil)
+ expected := []byte("Hello")
+
+ if result == nil {
+ t.Fatal("Expected non-nil result when callback returns array of integers")
+ }
+
+ if len(result) != len(expected) {
+ t.Fatalf("Expected result length %d, got %d", len(expected), len(result))
+ }
+
+ for i, b := range result {
+ if b != expected[i] {
+ t.Errorf("Expected byte at index %d to be %d, got %d", i, expected[i], b)
+ }
+ }
+}
+
+func TestOnData_ReturnsDynamicArray(t *testing.T) {
+ jsCode := `
+ function onData(from, to, data, callback) {
+ var result = [];
+ for (var i = 0; i < data.length; i++) {
+ result.push((data[i] + 1) % 256);
+ }
+ return result;
+ }
+ `
+
+ plug, err := plugin.Parse(jsCode)
+ if err != nil {
+ t.Fatalf("Failed to parse plugin: %v", err)
+ }
+
+ script := &TcpProxyScript{
+ Plugin: plug,
+ doOnData: plug.HasFunc("onData"),
+ }
+
+ from := &net.TCPAddr{IP: net.ParseIP("192.168.1.1"), Port: 1234}
+ to := &net.TCPAddr{IP: net.ParseIP("192.168.1.2"), Port: 5678}
+ data := []byte{10, 20, 30, 40, 255}
+
+ result := script.OnData(from, to, data, nil)
+ expected := []byte{11, 21, 31, 41, 0} // 255 + 1 = 256 % 256 = 0
+
+ if result == nil {
+ t.Fatal("Expected non-nil result when callback returns array of integers")
+ }
+
+ if len(result) != len(expected) {
+ t.Fatalf("Expected result length %d, got %d", len(expected), len(result))
+ }
+
+ for i, b := range result {
+ if b != expected[i] {
+ t.Errorf("Expected byte at index %d to be %d, got %d", i, expected[i], b)
+ }
+ }
+}
From fc65cde72855a7b05e0c7903aab2b08c70e98578 Mon Sep 17 00:00:00 2001
From: evilsocket
Date: Mon, 18 Aug 2025 17:08:42 +0200
Subject: [PATCH 11/15] releasing version 2.41.3
---
core/banner.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/banner.go b/core/banner.go
index 860d1e49..5fdcebae 100644
--- a/core/banner.go
+++ b/core/banner.go
@@ -2,7 +2,7 @@ package core
const (
Name = "bettercap"
- Version = "2.41.2"
+ Version = "2.41.3"
Author = "Simone 'evilsocket' Margaritelli"
Website = "https://bettercap.org/"
)
From 42da6121131a222ea8ceda1810884733fa9a4224 Mon Sep 17 00:00:00 2001
From: evilsocket
Date: Mon, 18 Aug 2025 19:14:05 +0200
Subject: [PATCH 12/15] hotfix: hotfix 2 for tcp.proxy
---
modules/tcp_proxy/tcp_proxy_script.go | 78 +++++++---------------
modules/tcp_proxy/tcp_proxy_script_test.go | 51 ++++++++++++++
2 files changed, 75 insertions(+), 54 deletions(-)
diff --git a/modules/tcp_proxy/tcp_proxy_script.go b/modules/tcp_proxy/tcp_proxy_script.go
index 60f103ea..50956ea0 100644
--- a/modules/tcp_proxy/tcp_proxy_script.go
+++ b/modules/tcp_proxy/tcp_proxy_script.go
@@ -1,6 +1,7 @@
package tcp_proxy
import (
+ "encoding/json"
"net"
"strings"
@@ -62,60 +63,29 @@ func (s *TcpProxyScript) OnData(from, to net.Addr, data []byte, callback func(ca
}
func toByteArray(ret interface{}) []byte {
- // Handle different array types that otto.Export() might return
- switch v := ret.(type) {
- case []interface{}:
- // Mixed type array
- result := make([]byte, len(v))
- for i, elem := range v {
- if num, ok := toNumber(elem); ok && num >= 0 && num <= 255 {
- result[i] = byte(num)
- } else {
- log.Error("array element at index %d is not a valid byte value %+v", i, elem)
- return nil
- }
- }
- return result
- case []int64:
- // Array of integers
- result := make([]byte, len(v))
- for i, num := range v {
- if num >= 0 && num <= 255 {
- result[i] = byte(num)
- } else {
- log.Error("array element at index %d is not a valid byte value %d", i, num)
- return nil
- }
- }
- return result
- case []float64:
- // Array of floats
- result := make([]byte, len(v))
- for i, num := range v {
- if num >= 0 && num <= 255 {
- result[i] = byte(num)
- } else {
- log.Error("array element at index %d is not a valid byte value %f", i, num)
- return nil
- }
- }
- return result
- default:
- log.Error("unexpected array type returned from onData: %T, value = %+v", ret, ret)
- return nil
- }
-}
+ // this approach is a bit hacky but it handles all cases
-// toNumber tries to convert an interface{} to a float64
-func toNumber(v interface{}) (float64, bool) {
- switch n := v.(type) {
- case float64:
- return n, true
- case int64:
- return float64(n), true
- case int:
- return float64(n), true
- default:
- return 0, false
+ // serialize ret to JSON
+ if jsonData, err := json.Marshal(ret); err == nil {
+ // attempt to deserialize as []float64
+ var back2Array []float64
+ if err := json.Unmarshal(jsonData, &back2Array); err == nil {
+ result := make([]byte, len(back2Array))
+ for i, num := range back2Array {
+ if num >= 0 && num <= 255 {
+ result[i] = byte(num)
+ } else {
+ log.Error("array element at index %d is not a valid byte value %d", i, num)
+ return nil
+ }
+ }
+ return result
+ } else {
+ log.Error("failed to deserialize %+v to []float64: %v", ret, err)
+ }
+ } else {
+ log.Error("failed to serialize %+v to JSON: %v", ret, err)
}
+
+ return nil
}
diff --git a/modules/tcp_proxy/tcp_proxy_script_test.go b/modules/tcp_proxy/tcp_proxy_script_test.go
index cb09b052..27bdc099 100644
--- a/modules/tcp_proxy/tcp_proxy_script_test.go
+++ b/modules/tcp_proxy/tcp_proxy_script_test.go
@@ -116,3 +116,54 @@ func TestOnData_ReturnsDynamicArray(t *testing.T) {
}
}
}
+
+func TestOnData_ReturnsMixedArray(t *testing.T) {
+ jsCode := `
+ function charToInt(value) {
+ return value.charCodeAt()
+ }
+
+ function onData(from, to, data) {
+ st_data = String.fromCharCode.apply(null, data)
+ if( st_data.indexOf("mysearch") != -1 ) {
+ payload = "mypayload";
+ st_data = st_data.replace("mysearch", payload);
+ res_int_arr = st_data.split("").map(charToInt) // []uint16
+ res_int_arr[0] = payload.length + 1; // first index is float64 and rest []uint16
+ return res_int_arr;
+ }
+ return data;
+ }
+ `
+
+ plug, err := plugin.Parse(jsCode)
+ if err != nil {
+ t.Fatalf("Failed to parse plugin: %v", err)
+ }
+
+ script := &TcpProxyScript{
+ Plugin: plug,
+ doOnData: plug.HasFunc("onData"),
+ }
+
+ from := &net.TCPAddr{IP: net.ParseIP("192.168.1.1"), Port: 1234}
+ to := &net.TCPAddr{IP: net.ParseIP("192.168.1.6"), Port: 5678}
+ data := []byte("Hello mysearch world")
+
+ result := script.OnData(from, to, data, nil)
+ expected := []byte("\x0aello mypayload world")
+
+ if result == nil {
+ t.Fatal("Expected non-nil result when callback returns array of integers")
+ }
+
+ if len(result) != len(expected) {
+ t.Fatalf("Expected result length %d, got %d", len(expected), len(result))
+ }
+
+ for i, b := range result {
+ if b != expected[i] {
+ t.Errorf("Expected byte at index %d to be %d, got %d", i, expected[i], b)
+ }
+ }
+}
From 4ec2753fad4a26096ea5c4cc11a38baaf39a3830 Mon Sep 17 00:00:00 2001
From: evilsocket
Date: Mon, 18 Aug 2025 19:15:44 +0200
Subject: [PATCH 13/15] releasing version 2.41.4
---
core/banner.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/banner.go b/core/banner.go
index 5fdcebae..1a63f0c8 100644
--- a/core/banner.go
+++ b/core/banner.go
@@ -2,7 +2,7 @@ package core
const (
Name = "bettercap"
- Version = "2.41.3"
+ Version = "2.41.4"
Author = "Simone 'evilsocket' Margaritelli"
Website = "https://bettercap.org/"
)
From 204997c8b51af7bc3c2c68ecfb232bbfcb840207 Mon Sep 17 00:00:00 2001
From: evilsocket
Date: Sat, 23 Aug 2025 14:22:11 +0200
Subject: [PATCH 14/15] misc: small fix or general refactoring i did not bother
commenting
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index 299e1d78..c1ecdf39 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,10 @@
+
+
+
+
From 1001cea8f2af70fdcafae1dc08be3e52a17a7bbf Mon Sep 17 00:00:00 2001
From: evilsocket
Date: Sat, 23 Aug 2025 17:12:07 +0200
Subject: [PATCH 15/15] misc: small fix or general refactoring i did not bother
commenting
---
README.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/README.md b/README.md
index c1ecdf39..ed1a583b 100644
--- a/README.md
+++ b/README.md
@@ -16,9 +16,7 @@
-
-
-
+