Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
coco
Commits
b9bc53d1
Unverified
Commit
b9bc53d1
authored
Aug 08, 2019
by
老广
Committed by
GitHub
Aug 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #260 from jumpserver/dev
Dev
parents
7e654cd6
6dfb4cb0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
22 deletions
+45
-22
README.md
README.md
+4
-0
conf.py
coco/conf.py
+1
-0
connection.py
coco/connection.py
+25
-18
ws.py
coco/httpd/ws.py
+9
-0
sshd.py
coco/sshd.py
+2
-3
tasks.py
coco/tasks.py
+1
-1
config_example.yml
config_example.yml
+3
-0
No files found.
README.md
View file @
b9bc53d1
...
@@ -7,6 +7,10 @@ It's implement a ssh server and a web terminal server,
...
@@ -7,6 +7,10 @@ It's implement a ssh server and a web terminal server,
User can connect them except jumpserver openssh server and connect.py
User can connect them except jumpserver openssh server and connect.py
pre version.
pre version.
# Warning
Coco has been replace by
[
koko
](
https://github.com/jumpserver/koko.git
)
From v1.5.2, coco will be stop update
## Install
## Install
...
...
coco/conf.py
View file @
b9bc53d1
...
@@ -377,6 +377,7 @@ defaults = {
...
@@ -377,6 +377,7 @@ defaults = {
'UPLOAD_FAILED_REPLAY_ON_START'
:
True
,
'UPLOAD_FAILED_REPLAY_ON_START'
:
True
,
'REUSE_CONNECTION'
:
True
,
'REUSE_CONNECTION'
:
True
,
'FORCE_REMOVE_FOLDER'
:
False
,
'FORCE_REMOVE_FOLDER'
:
False
,
'TELNET_TTYPE'
:
'XTERM-256COLOR'
,
}
}
...
...
coco/connection.py
View file @
b9bc53d1
...
@@ -300,25 +300,31 @@ class TelnetConnection:
...
@@ -300,25 +300,31 @@ class TelnetConnection:
logger
.
info
(
msg
)
logger
.
info
(
msg
)
return
None
,
msg
return
None
,
msg
if
data
.
startswith
(
telnetlib
.
IAC
):
# 将数据以 \r\n 进行分割
self
.
option_negotiate
(
data
)
_data_list
=
data
.
split
(
b
'
\r\n
'
)
else
:
for
_data
in
_data_list
:
result
=
self
.
login_auth
(
data
)
if
not
_data
:
if
result
:
msg
=
'Successful asset connection.<{}>/<{}>/<{}>.'
.
format
(
self
.
client
.
user
,
self
.
system_user
.
username
,
self
.
asset
.
hostname
)
logger
.
info
(
msg
)
return
self
.
sock
,
None
elif
result
is
False
:
self
.
sock
.
close
()
msg
=
'Authentication failed.
\r\n
'
logger
.
info
(
msg
)
return
None
,
msg
elif
result
is
None
:
continue
continue
if
_data
.
startswith
(
telnetlib
.
IAC
):
self
.
option_negotiate
(
_data
)
else
:
result
=
self
.
login_auth
(
_data
)
if
result
:
msg
=
'Successful asset connection.<{}>/<{}>/<{}>.'
.
format
(
self
.
client
.
user
,
self
.
system_user
.
username
,
self
.
asset
.
hostname
)
logger
.
info
(
msg
)
return
self
.
sock
,
None
elif
result
is
False
:
self
.
sock
.
close
()
msg
=
'Authentication failed.
\r\n
'
logger
.
info
(
msg
)
return
None
,
msg
elif
result
is
None
:
continue
def
option_negotiate
(
self
,
data
):
def
option_negotiate
(
self
,
data
):
"""
"""
Telnet server option negotiate before connection
Telnet server option negotiate before connection
...
@@ -338,7 +344,8 @@ class TelnetConnection:
...
@@ -338,7 +344,8 @@ class TelnetConnection:
elif
x
==
telnetlib
.
DO
+
telnetlib
.
TTYPE
:
elif
x
==
telnetlib
.
DO
+
telnetlib
.
TTYPE
:
new_data_list
.
append
(
telnetlib
.
WILL
+
telnetlib
.
TTYPE
)
new_data_list
.
append
(
telnetlib
.
WILL
+
telnetlib
.
TTYPE
)
elif
x
==
telnetlib
.
SB
+
telnetlib
.
TTYPE
+
b
'
\x01
'
:
elif
x
==
telnetlib
.
SB
+
telnetlib
.
TTYPE
+
b
'
\x01
'
:
new_data_list
.
append
(
telnetlib
.
SB
+
telnetlib
.
TTYPE
+
b
'
\x00
'
+
b
'XTERM-256COLOR'
)
terminal_type
=
bytes
(
config
.
TELNET_TTYPE
,
encoding
=
'utf-8'
)
new_data_list
.
append
(
telnetlib
.
SB
+
telnetlib
.
TTYPE
+
b
'
\x00
'
+
terminal_type
)
elif
telnetlib
.
DO
in
x
:
elif
telnetlib
.
DO
in
x
:
new_data_list
.
append
(
x
.
replace
(
telnetlib
.
DO
,
telnetlib
.
WONT
))
new_data_list
.
append
(
x
.
replace
(
telnetlib
.
DO
,
telnetlib
.
WONT
))
elif
telnetlib
.
WILL
in
x
:
elif
telnetlib
.
WILL
in
x
:
...
...
coco/httpd/ws.py
View file @
b9bc53d1
...
@@ -72,13 +72,22 @@ class ProxyNamespace(BaseNamespace):
...
@@ -72,13 +72,22 @@ class ProxyNamespace(BaseNamespace):
client
.
chan
=
ws_proxy
client
.
chan
=
ws_proxy
self
.
emit
(
'room'
,
{
'room'
:
client_id
,
'secret'
:
secret
})
self
.
emit
(
'room'
,
{
'room'
:
client_id
,
'secret'
:
secret
})
join_room
(
client_id
)
join_room
(
client_id
)
if
not
asset_id
or
not
system_user_id
:
if
not
asset_id
or
not
system_user_id
:
msg
=
"Not asset id or system user id found"
.
format
(
asset_id
,
system_user_id
)
logger
.
error
(
msg
)
return
return
asset
=
app_service
.
get_asset
(
asset_id
)
asset
=
app_service
.
get_asset
(
asset_id
)
system_user
=
app_service
.
get_system_user
(
system_user_id
)
system_user
=
app_service
.
get_system_user
(
system_user_id
)
if
not
asset
or
not
system_user
:
if
not
asset
or
not
system_user
:
msg
=
"No asset or system user found {} {}: {} {}"
.
format
(
asset_id
,
system_user_id
,
asset
,
system_user
)
logger
.
error
(
msg
)
return
return
forwarder
=
ProxyServer
(
client
,
asset
,
system_user
)
forwarder
=
ProxyServer
(
client
,
asset
,
system_user
)
...
...
coco/sshd.py
View file @
b9bc53d1
...
@@ -99,12 +99,11 @@ class SSHServer:
...
@@ -99,12 +99,11 @@ class SSHServer:
t
.
start
()
t
.
start
()
transport
.
close
()
transport
.
close
()
except
paramiko
.
SSHException
as
e
:
except
paramiko
.
SSHException
as
e
:
logger
.
warnin
g
(
"SSH negotiation failed: {}"
.
format
(
e
))
logger
.
debu
g
(
"SSH negotiation failed: {}"
.
format
(
e
))
except
EOFError
as
e
:
except
EOFError
as
e
:
logger
.
warnin
g
(
"Handle connection EOF Error: {}"
.
format
(
e
))
logger
.
debu
g
(
"Handle connection EOF Error: {}"
.
format
(
e
))
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
"Unexpect error occur on handle connection: {}"
.
format
(
e
))
logger
.
error
(
"Unexpect error occur on handle connection: {}"
.
format
(
e
))
logger
.
error
(
e
,
exc_info
=
True
)
finally
:
finally
:
Connection
.
remove_connection
(
connection
.
id
)
Connection
.
remove_connection
(
connection
.
id
)
sock
.
close
()
sock
.
close
()
...
...
coco/tasks.py
View file @
b9bc53d1
...
@@ -22,7 +22,7 @@ class TaskHandler:
...
@@ -22,7 +22,7 @@ class TaskHandler:
session
=
Session
.
sessions
.
get
(
session_id
)
session
=
Session
.
sessions
.
get
(
session_id
)
if
session
:
if
session
:
session
.
terminate
()
session
.
terminate
()
app_service
.
finish_task
(
task
.
id
)
app_service
.
finish_task
(
task
.
id
)
def
handle
(
self
,
task
):
def
handle
(
self
,
task
):
func
=
self
.
routes
.
get
(
task
.
name
)
func
=
self
.
routes
.
get
(
task
.
name
)
...
...
config_example.yml
View file @
b9bc53d1
...
@@ -63,3 +63,6 @@ BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>
...
@@ -63,3 +63,6 @@ BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>
# 是否强制删除文件夹:(default false)
# 是否强制删除文件夹:(default false)
# FORCE_REMOVE_FOLDER: false
# FORCE_REMOVE_FOLDER: false
# Telnet连接协商使用的终端类型
# TELNET_TTYPE: XTERM-256COLOR
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment