diff --git a/README.md b/README.md
index 6d25517..018b61f 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,7 @@ https://infosecwriteups.com/403-bypass-lyncdiscover-microsoft-com-db2778458c33
- Intruder 模块 手动修改request包内容时,每写一个字符,要重新点击鼠标,将光标重新定位到要修改的位置
- Attack 显示不能切换别的 Intruder tab页,不然结果就不显示了,前端数据绑定问题,太菜了,还没想好怎么写
+
## License
This code is distributed under the [MIT license](https://github.com/yhy0/ChYing/blob/main/LICENSE). See [LICENSE](https://github.com/yhy0/ChYing/blob/main/LICENSE) in this directory.
diff --git a/app.go b/app.go
index 78d1fb5..4271a38 100644
--- a/app.go
+++ b/app.go
@@ -249,6 +249,10 @@ func (a *App) Decoder(str string, mode string) string {
return decoder.DecodeBase64(str)
case "EncodeBase64":
return decoder.EncodeBase64(str)
+ case "DecodeHex":
+ return decoder.DecodeHex(str)
+ case "EncodeHex":
+ return decoder.EncodeHex(str)
case "MD5":
return decoder.Md5(str)
default:
diff --git a/frontend/src/components/Decoder.vue b/frontend/src/components/Decoder.vue
index 1c0ad8b..19b377e 100644
--- a/frontend/src/components/Decoder.vue
+++ b/frontend/src/components/Decoder.vue
@@ -13,16 +13,19 @@
Decode
- Unicode
+ Unicode
- URL
+ URL
- Base64
+ Base64
- MD5
+ Hex
+
+
+ MD5
@@ -30,13 +33,16 @@
Encode
- Unicode
+ Unicode
- URL
+ URL
- Base64
+ Base64
+
+
+ Hex
@@ -46,59 +52,154 @@
\ No newline at end of file
+
+// 去除其他的选中效果
+function clearOtherChecks(exclude, index) {
+ const checks = [
+ 'DecodeUnicode',
+ 'DecodeURL',
+ 'DecodeBase64',
+ 'DecodeHex',
+ 'EncodeUnicode',
+ 'EncodeURL',
+ 'EncodeBase64',
+ 'EncodeHex',
+ 'DecodeMD5'
+ ]
+
+ for (const check of checks) {
+ if (check !== exclude) {
+ eval(check + '.value[index] = false')
+ eval(check + '.value.splice(index + 2)')
+ }
+ }
+}
+
+
+
+
+
\ No newline at end of file
diff --git a/test/decoder_test.go b/test/decoder_test.go
index 7dde02f..163d055 100644
--- a/test/decoder_test.go
+++ b/test/decoder_test.go
@@ -14,12 +14,14 @@ import (
func TestDecode(t *testing.T) {
fmt.Println(decoder.DecodeUnicode("\\u0048\\u0065\\u006c\\u006c\\u006f\\u002c\\u0020\\u4e16\\u754c\\u0021"))
- fmt.Println(decoder.DecodeURL("Hello%2C+%E4%B8%96%E7%95%8C%21"))
+ fmt.Println(decoder.DecodeURL("Hello%2C%20%E4%B8%96%E7%95%8C%2B%21"))
fmt.Println(decoder.DecodeBase64("SGVsbG8sIOS4lueVjCE="))
+ fmt.Println(decoder.DecodeHex("48656c6c6f2c20e4b896e7958c21"))
}
func TestEncode(t *testing.T) {
fmt.Println(decoder.EncodeUnicode("Hello, 世界!"))
- fmt.Println(decoder.EncodeURL("Hello, 世界!"))
+ fmt.Println(decoder.EncodeURL("Hello, 世界+!"))
fmt.Println(decoder.EncodeBase64("Hello, 世界!"))
+ fmt.Println(decoder.EncodeHex("Hello, 世界!"))
}
diff --git a/tools/decoder/decode.go b/tools/decoder/decode.go
index 776449a..a53d409 100644
--- a/tools/decoder/decode.go
+++ b/tools/decoder/decode.go
@@ -2,6 +2,7 @@ package decoder
import (
"encoding/base64"
+ "encoding/hex"
"net/url"
"strconv"
"strings"
@@ -48,3 +49,17 @@ func DecodeBase64(str string) string {
}
return string(decoded)
}
+
+// DecodeHex hex 解码
+func DecodeHex(str string) string {
+ buf := make([]byte, hex.DecodedLen(len(str)))
+ n, err := hex.Decode(buf, []byte(str))
+
+ if err != nil {
+ return str
+ }
+ if n > 0 {
+ return string(buf)
+ }
+ return str
+}
diff --git a/tools/decoder/encode.go b/tools/decoder/encode.go
index 464eceb..28689c9 100644
--- a/tools/decoder/encode.go
+++ b/tools/decoder/encode.go
@@ -2,8 +2,10 @@ package decoder
import (
"encoding/base64"
+ "encoding/hex"
"fmt"
"net/url"
+ "strings"
)
/**
@@ -23,10 +25,19 @@ func EncodeUnicode(str string) string {
// EncodeURL URL 编码
func EncodeURL(str string) string {
- return url.QueryEscape(str)
+ encoded := url.QueryEscape(str) // 这个函数会将空格,替换为+
+ encoded = strings.ReplaceAll(encoded, "+", "%20") // 这里再将+ 替换为 %2B
+ return encoded
}
// EncodeBase64 Base64 编码
func EncodeBase64(str string) string {
return base64.StdEncoding.EncodeToString([]byte(str))
}
+
+// EncodeHex hex 编码
+func EncodeHex(str string) string {
+ buf := make([]byte, hex.EncodedLen(len(str)))
+ hex.Encode(buf, []byte(str))
+ return string(buf)
+}