forked from lazybootsafe/Go-Learning-With-Hack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcall-so.py
78 lines (64 loc) · 1.66 KB
/
call-so.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# coding:utf-8
import sys
import time
import json
from ctypes import *
def _args_encode(args_string):
'''Encode by utf-8 in PY3.'''
if sys.version_info >= (3, 0):
args_string = args_string.encode('utf-8')
return args_string
# 加载动态连接库
#by finger:此文件最好最新编译或者在官方项目地址的release下载最新so文件,但是我们学习go语言的话,还是自行编译较好
#还有就是二次开发
kunpeng = cdll.LoadLibrary('./kunpeng_c.so')
# 定义出入参变量类型
kunpeng.GetPlugins.restype = c_char_p
kunpeng.Check.argtypes = [c_char_p]
kunpeng.Check.restype = c_char_p
kunpeng.SetConfig.argtypes = [c_char_p]
kunpeng.GetVersion.restype = c_char_p
print(kunpeng.GetVersion())
# 获取插件信息
out = kunpeng.GetPlugins()
# 修改配置
config = {
'timeout': 10,
# 'aider': 'http://xxxx:8080',
# 'http_proxy': 'http://xxxxx:1080',
# 'pass_list':['xtest']
# 'extra_plugin_path': '/home/test/plugin/',
}
conf_args = json.dumps(config)
kunpeng.SetConfig(_args_encode(conf_args))
# 开启日志打印
kunpeng.ShowLog()
# 扫描目标
task = {
'type': 'web',
'netloc': 'http://www.google.cn',
'target': 'web',
'meta':{
'system': '',
'pathlist':[],
'filelist':[],
'passlist':[]
}
}
task2 = {
'type': 'service',
'netloc': '192.168.0.105:3306',
'target': 'mysql',
'meta':{
'system': '',
'pathlist':[],
'filelist':[],
'passlist':[]
}
}
task = _args_encode(json.dumps(task))
task2 = _args_encode(json.dumps(task2))
out = kunpeng.Check(task)
print(json.loads(out))
out = kunpeng.Check(task2)
print(json.loads(out))