mirror of https://github.com/cowrie/cowrie.git
Fixed scp command (#524)
* It doesn't hang anymore * Cut scp header from saved file
This commit is contained in:
parent
e90c5f9024
commit
7463a61879
|
@ -26,7 +26,7 @@
|
||||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
|
|
||||||
import getopt
|
import getopt, re, os
|
||||||
|
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
|
|
||||||
|
@ -77,6 +77,25 @@ class command_scp(HoneyPotCommand):
|
||||||
format='INPUT (%(realm)s): %(input)s')
|
format='INPUT (%(realm)s): %(input)s')
|
||||||
self.protocol.terminal.write( '\x00' )
|
self.protocol.terminal.write( '\x00' )
|
||||||
|
|
||||||
|
def handle_CTRL_D(self):
|
||||||
|
|
||||||
|
if self.protocol.terminal.stdinlogOpen and self.protocol.terminal.stdinlogFile and \
|
||||||
|
os.path.exists(self.protocol.terminal.stdinlogFile):
|
||||||
|
with open(self.protocol.terminal.stdinlogFile, 'rb') as f:
|
||||||
|
data = f.read()
|
||||||
|
header = data[:data.find('\n')]
|
||||||
|
if re.match('C0[\d]{3} [\d]+ [^\s]+', header):
|
||||||
|
data = data[data.find('\n')+1:]
|
||||||
|
else:
|
||||||
|
data = ''
|
||||||
|
|
||||||
|
if data:
|
||||||
|
with open(self.protocol.terminal.stdinlogFile, 'wb') as f:
|
||||||
|
f.write(data)
|
||||||
|
|
||||||
|
|
||||||
|
self.exit()
|
||||||
|
|
||||||
commands['/usr/bin/scp'] = command_scp
|
commands['/usr/bin/scp'] = command_scp
|
||||||
|
|
||||||
# vim: set sw=4 et:
|
# vim: set sw=4 et:
|
||||||
|
|
Loading…
Reference in New Issue