1
1
package commands
2
2
3
3
import (
4
- "bufio"
5
4
"fmt"
6
5
"log"
7
- "os"
8
- "regexp"
9
6
"ret/theme"
7
+ "ret/util"
10
8
)
11
9
12
10
func syscallHelp () {
@@ -26,26 +24,6 @@ func syscallHelp() {
26
24
fmt .Printf (" 🔗 " + theme .ColorGray + "https://github.com/rerrorctf/ret/blob/main/commands/syscall.go" + theme .ColorReset + "\n " )
27
25
}
28
26
29
- func grep (path string , pattern string ) {
30
- file , err := os .Open (path )
31
- if err != nil {
32
- log .Fatalf ("💥 " + theme .ColorRed + "error" + theme .ColorReset + ": opening file %v\n " , path )
33
- }
34
- defer file .Close ()
35
-
36
- scanner := bufio .NewScanner (file )
37
- for scanner .Scan () {
38
- line := scanner .Text ()
39
- if match , _ := regexp .MatchString (pattern , line ); match {
40
- fmt .Println (line )
41
- }
42
- }
43
-
44
- if err := scanner .Err (); err != nil {
45
- log .Fatalf ("💥 " + theme .ColorRed + "error" + theme .ColorReset + ": %v\n " , err )
46
- }
47
- }
48
-
49
27
func Syscall (args []string ) {
50
28
if len (args ) > 0 {
51
29
switch args [0 ] {
@@ -68,19 +46,19 @@ func Syscall(args []string) {
68
46
switch arch {
69
47
case "x86" :
70
48
{
71
- grep ("/usr/include/x86_64-linux-gnu/asm/unistd_32.h" , pattern )
49
+ util . Grep ("/usr/include/x86_64-linux-gnu/asm/unistd_32.h" , pattern )
72
50
}
73
51
case "32" :
74
52
{
75
- grep ("/usr/include/x86_64-linux-gnu/asm/unistd_32.h" , pattern )
53
+ util . Grep ("/usr/include/x86_64-linux-gnu/asm/unistd_32.h" , pattern )
76
54
}
77
55
case "x64" :
78
56
{
79
- grep ("/usr/include/x86_64-linux-gnu/asm/unistd_64.h" , pattern )
57
+ util . Grep ("/usr/include/x86_64-linux-gnu/asm/unistd_64.h" , pattern )
80
58
}
81
59
case "64" :
82
60
{
83
- grep ("/usr/include/x86_64-linux-gnu/asm/unistd_64.h" , pattern )
61
+ util . Grep ("/usr/include/x86_64-linux-gnu/asm/unistd_64.h" , pattern )
84
62
}
85
63
default :
86
64
{
0 commit comments