Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
jumpserver
Commits
54da30d9
Commit
54da30d9
authored
10 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改配置文件为相对路径,不用再指定目录了
parent
838b10d3
master
auditor_jym
audits
dev
dev_beta
dev_beta_db
gengmei
lagacy-0.4.0
node_service
password
rbac
restrict_access
test
v52
wph
1.5.2
1.5.1
1.5.0
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.0
0.3.3
0.3.2
0.3.2-rc2
0.3.1
0.3.0-beta
0.2.1
0.2.0
0.1.1
v1.4.10
v1.4.7
v1.4.4
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
19 deletions
+60
-19
Project_Default.xml
.idea/inspectionProfiles/Project_Default.xml
+8
-0
profiles_settings.xml
.idea/inspectionProfiles/profiles_settings.xml
+8
-0
jumpserver.iml
.idea/jumpserver.iml
+1
-1
jumpserver.py
jumpserver.py
+17
-5
jumpserver.sh
scripts/jumpserver.sh
+0
-0
pip-requirement.txt
scripts/pip-requirement.txt
+0
-0
settings.py
webroot/AutoSa/AutoSa/settings.py
+13
-13
models.py
webroot/AutoSa/UserManage/models.py
+13
-0
No files found.
.idea/inspectionProfiles/Project_Default.xml
0 → 100644
View file @
54da30d9
<component
name=
"InspectionProjectProfileManager"
>
<profile
version=
"1.0"
is_locked=
"false"
>
<option
name=
"myName"
value=
"Project Default"
/>
<option
name=
"myLocal"
value=
"false"
/>
<inspection_tool
class=
"SqlDialectInspection"
enabled=
"false"
level=
"WARNING"
enabled_by_default=
"false"
/>
</profile>
</component>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
.idea/inspectionProfiles/profiles_settings.xml
0 → 100644
View file @
54da30d9
<component
name=
"InspectionProjectProfileManager"
>
<settings>
<option
name=
"PROJECT_PROFILE"
value=
"Project Default"
/>
<option
name=
"USE_PROJECT_PROFILE"
value=
"true"
/>
<version
value=
"1.0"
/>
</settings>
</component>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
.idea/jumpserver.iml
View file @
54da30d9
...
...
@@ -2,7 +2,7 @@
<module
type=
"PYTHON_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$"
/>
<orderEntry
type=
"jdk"
jdkName=
"Python 2.7.
6 (C:/Python27/
python.exe)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"jdk"
jdkName=
"Python 2.7.
8 (C:\Python27\
python.exe)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
...
...
This diff is collapsed.
Click to expand it.
jumpserver.py
View file @
54da30d9
#!/usr/bin/python
# coding: utf-8
cur_dir
=
os
.
path
.
dirname
(
__file__
)
sys
.
path
.
append
(
'
%
s/webroot/AutoSA/'
%
cur_dir
)
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'AutoSa.settings'
import
os
import
sys
import
subprocess
import
MySQLdb
import
pexpect
import
struct
import
fcntl
import
termios
...
...
@@ -17,10 +20,11 @@ from binascii import b2a_hex, a2b_hex
import
ConfigParser
import
paramiko
import
pxssh
from
UserManage.models
import
User
base_dir
=
"/opt/jumpserver/"
cf
=
ConfigParser
.
ConfigParser
()
cf
.
read
(
'
%
s/jumpserver.conf'
%
base
_dir
)
cf
.
read
(
'
%
s/jumpserver.conf'
%
cur
_dir
)
db_host
=
cf
.
get
(
'db'
,
'host'
)
db_port
=
cf
.
getint
(
'db'
,
'port'
)
...
...
@@ -34,6 +38,8 @@ assets_user_table = cf.get('jumpserver', 'assets_user_table')
key
=
cf
.
get
(
'jumpserver'
,
'key'
)
class
PyCrypt
(
object
):
"""It's used to encrypt and decrypt password."""
def
__init__
(
self
,
key
):
...
...
@@ -112,8 +118,11 @@ def connect(host, port, user, password):
log_date_dir
=
'
%
s/
%
s'
%
(
log_dir
,
time
.
strftime
(
'
%
Y
%
m
%
d'
))
if
not
os
.
path
.
isdir
(
log_date_dir
):
os
.
mkdir
(
log_date_dir
)
logfile
=
open
(
"
%
s/
%
s_
%
s"
%
(
log_date_dir
,
host
,
user
),
'a'
)
logfile
.
write
(
'
\n\n
%
s
\n\n
'
%
time
.
strftime
(
'
%
Y
%
m
%
d_
%
H
%
M
%
S'
))
logfile
=
open
(
"
%
s/
%
s_
%
s_
%
s"
%
(
log_date_dir
,
host
,
user
,
time
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
M
%
S'
)),
'a'
)
db
,
cursor
=
connect_db
(
db_user
,
db_password
,
db_db
,
db_host
,
db_port
)
cursor
.
execute
(
'insert into logs (Fuser, Fhost, Flogfile, Fstart_time) value (
%
s,
%
s,
%
s, UNIX_TIMESTAMP())'
%
(
user
,
host
,
logfile
))
logfile
.
write
(
'
\n
%
s
\n
'
%
time
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
))
try
:
global
foo
foo
=
pxssh
.
pxssh
()
...
...
@@ -122,10 +131,13 @@ def connect(host, port, user, password):
foo
.
sendline
(
''
)
signal
.
signal
(
signal
.
SIGWINCH
,
sigwinch_passthrough
)
foo
.
interact
(
escape_character
=
chr
(
28
))
cursor
.
execute
(
'update logs set Ffindsh=True, Fend_time=UNIX_TIMESTAMP() where Flogfile=
%
s'
%
logfile
)
except
pxssh
.
ExceptionPxssh
as
e
:
print
(
'登录失败:
%
s'
%
e
)
cursor
.
execute
(
'update logs set Ffindsh=2 where Flogfile=
%
s'
%
logfile
)
except
KeyboardInterrupt
:
foo
.
logout
()
cursor
.
execute
(
'update logs set Ffindsh=True, Fend_time=UNIX_TIMESTAMP() where Flogfile=
%
s '
%
logfile
)
def
ip_all_select
(
username
):
...
...
This diff is collapsed.
Click to expand it.
jumpserver.sh
→
scripts/
jumpserver.sh
100755 → 100644
View file @
54da30d9
File moved
This diff is collapsed.
Click to expand it.
pip-requirement.txt
→
scripts/
pip-requirement.txt
View file @
54da30d9
File moved
This diff is collapsed.
Click to expand it.
webroot/AutoSa/AutoSa/settings.py
View file @
54da30d9
...
...
@@ -12,16 +12,16 @@ https://docs.djangoproject.com/en/1.6/ref/settings/
import
os
import
ConfigParser
base_dir
=
"/opt/jumpserver/"
cf
=
ConfigParser
.
ConfigParser
()
cf
.
read
(
'
%
s/jumpserver.conf'
%
base_dir
)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
CONF_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
BASE_DIR
))
CF
=
ConfigParser
.
ConfigParser
()
CF
.
read
(
'
%
s/jumpserver.conf'
%
CONF_DIR
)
db_host
=
cf
.
get
(
'db'
,
'host'
)
db_port
=
cf
.
getint
(
'db'
,
'port'
)
db_user
=
cf
.
get
(
'db'
,
'user'
)
db_password
=
cf
.
get
(
'db'
,
'password'
)
db_db
=
cf
.
get
(
'db'
,
'db'
)
DB_HOST
=
CF
.
get
(
'db'
,
'host'
)
DB_PORT
=
CF
.
getint
(
'db'
,
'port'
)
DB_USER
=
CF
.
get
(
'db'
,
'user'
)
DB_PASSWORD
=
CF
.
get
(
'db'
,
'password'
)
DB_DB
=
CF
.
get
(
'db'
,
'db'
)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
...
...
@@ -71,11 +71,11 @@ WSGI_APPLICATION = 'AutoSa.wsgi.application'
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.mysql'
,
'NAME'
:
db_db
,
'USER'
:
db_user
,
'PASSWORD'
:
db_password
,
'HOST'
:
db_host
,
'PORT'
:
db_port
,
'NAME'
:
DB_DB
,
'USER'
:
DB_USER
,
'PASSWORD'
:
DB_PASSWORD
,
'HOST'
:
DB_HOST
,
'PORT'
:
DB_PORT
,
}
}
...
...
This diff is collapsed.
Click to expand it.
webroot/AutoSa/UserManage/models.py
View file @
54da30d9
...
...
@@ -23,3 +23,16 @@ class User(models.Model):
return
self
.
username
class
Logs
(
models
.
Model
):
user
=
models
.
CharField
(
max_length
=
50
)
host
=
models
.
CharField
(
max_length
=
20
)
logfile
=
models
.
CharField
(
max_length
=
1000
)
finish
=
models
.
SmallIntegerField
(
max_length
=
4
)
start_time
=
models
.
IntegerField
()
end_time
=
models
.
IntegerField
()
def
__unicode__
(
self
):
return
self
.
logfile
This diff is collapsed.
Click to expand it.
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