Yearning SQL 审计平台 基于Vue.js与Django的整套mysql-sql审核平台解决方案。提供基于Inception的SQL检测及执行。
GitHub:https://github.com/cookieY/Yearning
文档:http://guide.yearning.io/used/
1. 安装nginx,mysql,python3.6,node8.5
yum install -y nginx
解压node,做软链接即可
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm --force --nodeps
yum install mysql-server
启动及查看mysql初始密码:systemctl start mysqld && grep 'temporary password' /var/log/mysqld.log
修改mysql密码: mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; #5.7对密码复杂度有要求 下载python3.6:wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
解压安装: tar xzf Python-3.6.3.tgz && cd Python-3.6.3
./configure --prefix=/usr/local/python3 --with-ssl && make && make install
查看是否安装成功及当前python版本:echo $?
python -V
备份文件:cp /usr/bin/python /usr/bin/python2.7.5
ln -fs /usr/local/python3/bin/python3.6 /usr/bin/python
ln -fs /usr/local/python3/bin/pip3 /usr/bin/pip
修改yum文件为之前备份的python:vim /usr/bin/yum /usr/libexec/urlgrabber-ext-down第一行修改为#!/usr/bin/python2.7.5 #不修改yum安装文件会报错
2. 下载安装inception
git clone https://github.com/cookieY/Yearning.git
cd Yearning/install && tar xzf inception.tar && cd inception
cat ./bin/inc.cnf
[inception]
general_log=1
general_log_file=inception.log
port=6669 #inception端口 socket=/tmp/inc.socket
character-set-client-handshake=0
character-set-server=utf8
inception_support_charset=utf8mb4
inception_enable_nullable=1 #此处改为1,否则执行sql为NULL的会报错
inception_check_primary_key=1
inception_check_column_comment=1
inception_check_table_comment=1
inception_enable_blob_type=1
inception_check_column_default_value=1
inception_support_charset=utf8
inception_osc_on=OFF
inception_check_column_default_value=OFF
inception_check_column_comment=OFF
inception_check_table_comment=OFF
inception_enable_identifer_keyword=ON
inception_remote_backup_host = 127.0.0.1 #备份库IP
inception_remote_backup_port = 3306 #备份库端口
inception_remote_system_user = root #备份库用户
inception_remote_system_password = Zhletou@2019 #备份库密码
启动inception nohup ./bin/Inception --defaults-file=./bin/inc.cnf &
     检查是否启动成功:mysql -u root -P 6669 -h 127.0.0.1
     inception get variables; #输出配置的变量则启动OK
3. 配置安装yearning
cd Yearning/src
cp deploy.conf.template ./deploy.conf
cat deploy.conf
db = Yearning
address = 192.168.0.203
port = 3306
username = yearning
password = yearning [host]
ipaddress = 192.168.0.203:80 #后续访问yearning的地址和端口
安装python依赖包
pip install -r requirements.txt
python3.6 错误: ModuleNotFoundError:No module named "Crypto"
pip install pycryptodome
创建数据库:create database yearning charset utf8;
授权: grant all privileges on *.* to yearning@'%' identified by
'yearning'
导入配置sql:mysql -uyearning -pyearning yearning <
Yearning/install/yearning-docker-compose/init-sql/install.sql #后续如果不小心删除了权限组,导致管理员无法配置,需要重新导入sql,重新配置,所以建议备份其数据库
替换连接数据库文件:find / -name connections.py 进入到文件目录进行替换 #可百度或者找官网的文件
找到 connections.py 1108行
ifint(self.server_version.split('.',1)[0]) >=5:self.client_flag|= CLIENT.MULTI_RESULTS更改为try:ifint(self.server_version.split('.',1)[0]) >=5:self.client_flag |= CLIENT.MULTI_RESULTSexcept:
ifself.server_version.split('.',1)[0] >='Inception2':self.client_flag |= CLIENT.MULTI_RESULTS
找到 cursors.py 345行ifself._resultand(self._result.has_nextornotself._result.warning_count):return更改为ifself._result:return
   cd Yearning/webpage
npm install
   如执行npm install 报错可执行npm install phantomjs-prebuilt@2.1.16 --ignore-scripts
npm run build
启动:nohup python manage.py runserver 0.0.0.0:8000 &
3. 配置nginx
vim /etc/nginx/conf.d/default.conf
server {
listen 80;
#server_name 192.168.0.203;
server_name yearning.server.com;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main; location / {
root /Yearning/Yearning/webpage/dist;
index index.html index.htm;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
4. 启动nginx
systemctl start nginx && systemctl enable nginx
http://yearning.server.com即可访问
5. 配置inception,邮件及钉钉
登录yaerning 默认用户及密码:admin/Yearning_admin
设置-->配置inception #配置项为inc.cnf里面配置的用户及密码 注:要备份数据,执行的数据库必须开启二进制日志及server-id不能为0和1
cat /etc/my.cnf
user=mysql
server-id=3546346
log-bin=/home/data/mysql/data
binlog-format=ROW
binlog_row_image=full

附上inception参数
vim /etc/inc.cnf [inception] general_log=1 #这个参数就是原生的MySQL的参数,用来记录在Inception服务上执行过哪些语句,用来定位一些问题等 general_log_file=/usr/local/inception/data/inception.log #设置general log写入的文件路径 port=6669 #Inception的服务端口 socket=/usr/local/inception/data/inc.socket #Inception的套接字文件存放位置 character-set-server=utf8 #mysql原生参数 #Inception 审核规则 inception_check_autoincrement_datatype=1 #当建表时自增列的类型不为int或者bigint时报错 inception_check_autoincrement_init_value=1 #当建表时自增列的值指定的不为1,则报错 inception_check_autoincrement_name=1 #建表时,如果指定的自增列的名字不为ID,则报错,说明是有意义的,给提示 inception_check_column_comment=1 #建表时,列没有注释时报错 inception_check_column_default_value=0 #检查在建表、修改列、新增列时,新的列属性是不是要有默认值 inception_check_dml_limit=1 #在DML语句中使用了LIMIT时,是不是要报错 inception_check_dml_orderby=1 #在DML语句中使用了Order By时,是不是要报错 inception_check_dml_where=1 #在DML语句中没有WHERE条件时,是不是要报错 inception_check_identifier=1 #打开与关闭Inception对SQL语句中各种名字的检查,如果设置为ON,则如果发现名字中存在除数字、字母、下划线之外的字符时,会报Identifier "invalidname" is invalid, valid options: [a-z,A-Z,0-9,_]. inception_check_index_prefix=1 #是不是要检查索引名字前缀为"idx_",检查唯一索引前缀是不是"uniq_" inception_check_insert_field=1 #是不是要检查插入语句中的列链表的存在性 inception_check_primary_key=1 #建表时,如果没有主键,则报错 inception_check_table_comment=0 #建表时,表没有注释时报错 inception_check_timestamp_default=0 #建表时,如果没有为timestamp类型指定默认值,则报错 inception_enable_autoincrement_unsigned=1 #自增列是不是要为无符号型 inception_enable_blob_type=0 #检查是不是支持BLOB字段,包括建表、修改列、新增列操作 默认开启 inception_enable_column_charset=0 #允许列自己设置字符集 inception_enable_enum_set_bit=0 #是不是支持enum,set,bit数据类型 inception_enable_foreign_key=0 #是不是支持外键 inception_enable_identifer_keyword=0 #检查在SQL语句中,是不是有标识符被写成MySQL的关键字,默认值为报警。 inception_enable_not_innodb=0 #建表指定的存储引擎不为Innodb,不报错 inception_enable_nullable=0 #创建或者新增列时如果列为NULL,不报错 inception_enable_orderby_rand=0 #order by rand时是不是报错 inception_enable_partition_table=0 #是不是支持分区表 inception_enable_select_star=0 #Select*时是不是要报错 inception_enable_sql_statistic=1 #设置是不是支持统计Inception执行过的语句中,各种语句分别占多大比例,如果打开这个参数,则每次执行的情况都会在备份数据库实例中的inception库的statistic表中以一录存储这次操作的统计情况,每次操作对应一条记录,这条记录中含有的信息是各种类型的语句执行次数情况。 inception_max_char_length=16 #当char类型的长度大于这个值时,就提示将其转换为VARCHAR inception_max_key_parts=5 #一个索引中,列的最大个数,超过这个数目则报错 inception_max_keys=16 #一个表中,最大的索引数目,超过这个数则报错 inception_max_update_rows=10000 #在一个修改语句中,预计影响的最大行数,超过这个数就报错 inception_merge_alter_table=1 #在多个改同一个表的语句出现是,报错,提示合成一个 #inception 支持 OSC 参数 inception_osc_bin_dir=/user/bin #用于指定pt-online-schema-change脚本的位置,不可修改,在配置文件中设置 inception_osc_check_interval=5 #对应OSC参数--check-interval,意义是Sleep time between checks for --max-lag. inception_osc_chunk_size=1000 #对应OSC参数--chunk-size inception_osc_chunk_size_limit=4 #对应OSC参数--chunk-size-limit inception_osc_chunk_time=0.1 #对应OSC参数--chunk-time inception_osc_critical_thread_connected=1000 #对应参数--critical-load中的thread_connected部分 inception_osc_critical_thread_running=80 #对应参数--critical-load中的thread_running部分 inception_osc_drop_new_table=1 #对应参数--[no]drop-new-table inception_osc_drop_old_table=1 #对应参数--[no]drop-old-table inception_osc_max_lag=3 #对应参数--max-lag inception_osc_max_thread_connected=1000 #对应参数--max-load中的thread_connected部分 inception_osc_max_thread_running=80 #对应参数--max-load中的thread_running部分 inception_osc_min_table_size=0 # 这个参数实际上是一个OSC的开关,如果设置为0,则全部ALTER语句都走OSC,如果设置为非0,则当这个表占用空间大小大于这个值时才使用OSC方式。单位为M,这个表大小的计算方式是通过语句:"select (DATA_LENGTH + INDEX_LENGTH)/1024/1024 from information_schema.tables where table_schema = 'dbname' and table_name = 'tablename'"来实现的 inception_osc_on=0 #一个全局的OSC开关,默认是打开的,如果想要关闭则设置为OFF,这样就会直接修改 inception_osc_print_none=1 #用来设置在Inception返回结果集中,对于原来OSC在执行过程的标准输出信息是不是要打印到结果集对应的错误信息列中,如果设置为1,就不打印,如果设置为0,就打印。而如果出现错误了,则都会打印 inception_osc_print_sql=1 #对应参数--print #备份服务器信息,注意改成你的机器.用于回滚。 inception_remote_system_password=P@ssw0rd inception_remote_system_user=incep_rw inception_remote_backup_port=3306 inception_remote_backup_host=10.10.3.70 inception_support_charset=utf8 #表示在建表或者建库时支持的字符集,如果需要多个,则用逗号分隔,影响的范围是建表、设置会话字符集、修改表字符集属性等

  

  

最新文章

  1. Html5绘制时钟
  2. 当在浏览器输入一个url访问后发生了什么
  3. 实时控制软件设计 第二次作业 myRobot
  4. 控制input标签中只能输入数字以及小数点后两位
  5. 数据结构算法C语言实现(九)--- 拓展:由迷宫问题引申的AI贪吃蛇
  6. assert函数
  7. VBS_DO...Loop
  8. 1018. Public Bike Management (30)
  9. Struts—自定义一个简单的mystruct
  10. webpack文档
  11. 解决ubuntu侧边栏固定应用单击无反应的问题
  12. OpenCV2.x自学笔记——最大类间方差法OTSU
  13. Excel as a Service &mdash;&mdash; Excel 开发居然可以这么玩
  14. 数据分析 大数据之路 五 pandas 报表
  15. tensorflow 使用 2 Felch ,Feed
  16. vue-cli 打包编译 -webkit-box-orient: vertical 被删除解决办法
  17. 20155219 付颖卓《基于ARM试验箱的接口应用于测试》课程设计个人报告
  18. 对map集合按照value从大到小进行排序
  19. c# 调apicontroller
  20. 转STM32官方固件库简介

热门文章

  1. mmdetection训练出现nan
  2. openlayers API实现鹰眼图OverviewMap时地图不断闪烁等问题的解决思路
  3. 使用aspnetcore前后端分离开发,你一定要知道这个
  4. 【图解】面试题:ConcurrentHashMap是如何保证线程安全的
  5. Java汽车租赁系统[源码+数据库]
  6. 基于.Net C# 通信开发-网络调试助手
  7. 鸭的NOI ONLINE杂刷
  8. 使用Spring MockMVC对controller做单元测试
  9. 使用NE555实现的延时开关电路
  10. 小米 pro 笔记本双硬盘设置引导盘