Skip to content

Commit 4e98da3

Browse files
committed
Update README
1 parent e3c6f5b commit 4e98da3

1 file changed

Lines changed: 259 additions & 6 deletions

File tree

README.rst

Lines changed: 259 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,263 @@
1-
.. image:: https://img.shields.io/pypi/v/sqlmapcli.svg
1+
.. image:: https://img.shields.io/pypi/v/sqlmapcli.svg
22
:target: https://pypi.python.org/pypi/sqlmapcli
33

4-
Simplify Your Operations For Sqlmapapi
4+
.. image:: https://img.shields.io/github/release/jetz/sqlmapcli.svg
5+
:target: http://www.github.com/jetz/sqlmapcli
6+
7+
.. image:: https://img.shields.io/github/license/mashape/apistatus.svg
8+
:target: https://github.com/jetz/sqlmapcli/blob/master/LICENSE
9+
10+
11+
Simplify Your Operations For SqlmapAPI
12+
13+
~~~~~
14+
15+
Intro
16+
======
17+
18+
This is a library used to simplify operations for sqlmapapi, you needn't
19+
manually request remote sqlmapapi server to create task, run task or others
20+
by HTTP, just a few steps as follow:
21+
22+
.. code:: python
23+
24+
def test():
25+
admin_id = '10af2eefc9606577bccb75ced1fa74db'
26+
c = client.Client(admin_id)
27+
task = c.create_task()
28+
r = task.run(url='http://testphp.vulnweb.com/artists.php?artist=1')
29+
print(r)
30+
c.delete_task(task.id)
31+
32+
33+
Installation
34+
============
35+
36+
.. code:: bash
37+
38+
pip install sqlmapcli
39+
40+
or
41+
42+
.. code:: bash
43+
44+
git clone https://www.github.com/jetz/sqlmapapi
45+
cd sqlmapcli && python setup.py install
46+
47+
48+
API
49+
====
50+
51+
Client
52+
------
53+
54+
**class sqlmapcli.Client(admin_id, host='127.0.0.1', port=8775)**
55+
56+
Call remote api to create/delete/list/flush task.
57+
58+
``admin_id`` is used to list & flush tasks, it can be obtained after starting
59+
a sqlmapapi server by ``sqlmapapi -s``. If use `sqlmap-proxy <https://github.com/jetz/sqlmap-proxy>`_, admin id is what you config.
60+
61+
62+
Methods
63+
+++++++
64+
65+
`Client.create_task(options=None)`
66+
67+
Returns task object. This method will create a task object on client side, and request to
68+
create a task on remote server side.
69+
70+
``options`` can be achieved by ``curl http://<host>:<port>/option/<taskid>/list``,
71+
alternatively, can set options in task object later.
72+
73+
74+
`Client.delete_task(self, taskid)`
75+
76+
Returns True if successful, False otherwise
77+
78+
Delete a remote task with it's taskid.
79+
80+
81+
`Client.list_tasks(self)`
82+
83+
Returns remote tasks info as dict.
84+
85+
List tasks's info of remote server side. It only requests remote
86+
sqlmapapi server and gets response, the tasks info are remote info, not
87+
local task objects created by ``Client.create_task`` method.
88+
89+
90+
`Client.flush_tasks(self)`
91+
92+
Returns True if flush successfully, False otherwise
93+
94+
Flush remote sqlmapapi server's tasks.
95+
96+
97+
98+
Task
99+
------
100+
101+
**class sqlmapcli.Task(id, options, addr)**
102+
103+
Returns a task object. Generally, ``Client.create_task`` do it for you.
104+
105+
Task id comes from remote sqlmapapi server.
106+
107+
All optional ``options`` can list by ``curl http://<host>:<port>/option/<taskid>/list``.
108+
109+
``addr`` is remote sqlmapapi server address.
110+
111+
112+
113+
Attributes
114+
++++++++++
115+
116+
`Task.ready`
117+
118+
It's True If task is created but not start, False otherwise.
119+
120+
121+
`Task.running`
122+
123+
It's True if task start but not finished, False otherwise.
124+
125+
126+
`Task.finished`
127+
128+
It's True if task is finished, False otherwise.
129+
130+
131+
Methods
132+
+++++++
133+
134+
`Task.set_option(key, value)`
135+
136+
Returns task object for chained call.
137+
138+
Set option for task. Options can be set when client create task, or call
139+
``set_option`` after task is created but not start. This method can be
140+
chain-called, like:
141+
142+
Example:
143+
144+
.. code:: python
145+
146+
task.set_option('url', 'http://testphp.vulnweb.com/artists.php?artist=1').set_option('dbms', 'mysql')
147+
148+
149+
`Task.get_option(key)`
150+
151+
Returns option value.
152+
153+
If key is not set, raise error
154+
155+
156+
`Task.update_options(options)`
157+
158+
Update bulk options at same time. ``options`` is a dict contains some
159+
valid values as ``set_option``.
160+
161+
162+
`Task.list_options()`
163+
164+
Returns all options that you have set.
165+
166+
NOTICE: not option list in remote server.
167+
168+
169+
`Task.start(url=None, options=None)`
170+
171+
Returns engineid, maybe useful in future.
172+
173+
``url`` is the target to scan by sqlmap, it's a shorthand for setting option
174+
with key `url`.
175+
176+
You can pass options here directly or `set_option` or `update_options` in task
177+
or pass options when create task, choose one way as you like.
178+
179+
Example:
180+
181+
.. code:: python
182+
183+
def test(admin_id):
184+
c = client.Client(admin_id)
185+
try:
186+
task = c.create_task()
187+
except:
188+
return
189+
task.set_option('url', 'http://testphp.vulnweb.com/artists.php?artist=1')
190+
task.start()
191+
while task.running:
192+
time.sleep(2)
193+
r = task.get_result()
194+
pprint(r)
195+
c.delete_task(task.id)
196+
197+
198+
`Task.stop()`
199+
200+
Returns True if stop successfully, False otherwise.
201+
202+
Stop running task.
203+
204+
205+
`Task.kill()`
206+
207+
Returns True if Kill successfully, False otherwise.
208+
209+
Kill running task unconditionally.
210+
211+
212+
`Task.status()`
213+
214+
Returns a dict contains `status` and `retcode`. It may raise TaskStatusError.
215+
216+
Task's current status, `not running`, `running`, `terminated`.
217+
218+
219+
`Task.get_result()`
220+
221+
Returns task data as dict. It may raise TaskResultError.
222+
223+
224+
`Task.get_log(start=None, end=None)`
225+
226+
Returns task log data as dict. It may raise TaskLogError.
227+
228+
If start & end is None, return all logs, otherwise return logs between start and end index.
229+
230+
231+
`Task.run(url=None, options=None, interval=5)`
232+
233+
Returns task result dict if successfully, None otherwise.
234+
235+
This method is shorthand for call ``start``, ``status`` and ``get_result``.
236+
237+
``url`` and ``options`` is same as ``start`` method.
238+
239+
``interval`` poll to check task status.
240+
241+
Example:
242+
243+
.. code:: python
244+
245+
def test(admin_id):
246+
c = client.Client(admin_id)
247+
try:
248+
task = c.create_task(options={'url':'http://testphp.vulnweb.com/artists.php?artist=1'})
249+
task.run()
250+
except:
251+
return
252+
print(r)
253+
r = c.list_tasks()
254+
print(r)
255+
c.delete_task(task.id)
256+
c.flush_tasks()
257+
5258
6259
TODO
7-
-----
8-
- [ ] docs
9-
- [ ] download
10-
- [ ] examples
260+
====
261+
262+
- more examples
263+
- download interface

0 commit comments

Comments
 (0)