-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXshelldecrypt.go
51 lines (43 loc) · 985 Bytes
/
Xshelldecrypt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package Xshelldecrypt
import (
"crypto/rc4"
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
"fmt"
"os/user"
"strings"
"golang.org/x/example/hello/reverse"
)
func Recovery(pwd string) {
curr, err := user.Current()
if err != nil {
fmt.Println("error:", err)
return
}
// Trim the domain
split := strings.SplitAfter(curr.Username, "\\")
name := split[len(split)-1]
ikm := reverse.String(curr.Uid) + name
decoded, err := base64.StdEncoding.DecodeString(pwd)
if err != nil {
fmt.Println("error:", err)
return
}
key := sha256.Sum256([]byte(ikm))
arc, err := rc4.NewCipher(key[:])
if err != nil {
fmt.Println("error:", err)
return
}
pt := make([]byte, len(decoded)-32)
arc.XORKeyStream(pt, decoded[:len(decoded)-32])
calculatedHash := sha256.Sum256(pt[:])
// Test the result
iv := decoded[len(decoded)-32:]
if subtle.ConstantTimeCompare(calculatedHash[:], iv) == 1 {
fmt.Println(string(pt))
} else {
fmt.Println("Decryption failed")
}
}