qark与jenkins集成运行命令提示termios.error: (22, ‘Invalid argument’)
Posted On 2016年11月14日
qark扫描代码时,提供了一个交互的界面,可以通过按键“C”,停止解压和反编译的代码。 仅对已经反编译的代码进行扫描。 但是jenkins直接调用这种python脚本,则会提示一个错误。
python /home/test/software/qark-latest/qark/qark/qarkMain.py --source 1 --pathtoapk /home/test/ci/jobs/ANDROID_SECURITY_SCAN/workspace/tobetest.apk --exploit 0 --install 0 -r /home/test/ci/jobs/ANDROID_SECURITY_SCAN/workspace
Traceback (most recent call last):
File "/home/test/software/qark-latest/qark/qark/qarkMain.py", line 1103, in <module>
nonAutomatedParseArgs()
File "/home/test/software/qark-latest/qark/qark/qarkMain.py", line 414, in nonAutomatedParseArgs
main()
File "/home/test/software/qark-latest/qark/qark/qarkMain.py", line 722, in main
unpackAPK.decompile(common.pathToDEX)
File "/usr/local/lib/python2.7/site-packages/qark-1.2.19-py2.7.egg/qark/modules/unpackAPK.py", line 157, in decompile
with common.term.cbreak():
File "/usr/local/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/site-packages/qark-1.2.19-py2.7.egg/qark/lib/blessed/terminal.py", line 572, in cbreak
save_mode = termios.tcgetattr(self.keyboard_fd)
termios.error: (22, 'Invalid argument')
我们应该如何运行此脚本避免此问题呢?
从忘上搜索,查到的解决方法并不有效。 所以我只能稍微hack下python代码了。
备注: 忘上的办法是用script命令进行包裹此脚本。即
script -c '/usr/local/bin/python /home/test/software/qark-latest/qark/qark/qarkMain.py --source 1 --pathtoapk /home/test/ci/jobs/ANDROID_SECURITY_SCAN/workspace/tobetest.apk --exploit 0 --install 0 -r /home/test/ci/jobs/ANDROID_SECURITY_SCAN/workspace' /dev/null
但是实际并没有成功。
hack的办法,把捕捉按键的代码注释掉。 直接修改如下代码。 (因为qark您安装的位置不同,可能目录会有差异)
/usr/local/lib/python2.7/site-packages/qark-1.2.19-py2.7.egg/qark/modules/unpackAPK.py
156 '''
157 with common.term.cbreak():
158 val = None
159 while val not in (u'c', u'C'):
160 with common.term.location(0,common.term.height-3):
161 print "Decompilation may hang/take too long (usually happens when the source is obfuscated)."
162 print "At any time," + common.term.bold_underline_red_on_white('Press C to continue') + " and QARK will attempt to run SCA on whatever was decompiled."
163 val = common.term.inkey(timeout=1)
164 if not (thread1.is_alive() or thread2.is_alive() or thread3.is_alive()):
165 break
166 '''
再次在jenkins中运行, 这下成功跳过了出错的地方。
此篇文章已被阅读5168 次
2 Comments
你好,我最近也在做把QARK集成到Jenkins中,其中遇到一个问题,我把qark的使用放到shell脚本中去执行,每次执行都会报代码错误;但是我直接在Linux环境中执行qark的使用命令就没有问题,不知道你有没有遇到同样的问题?如果有能不能告诉我一下解决方案,非常感谢~
是同样的错误吗??