Ubuntu搭建XSS平台 nginx+php5.6+mysql

重要!

因为网上搭建XSS平台的大多数都是用Apache来做Web服务器的,所以我就找了些资料用nginx进行搭建,其实很简单。

本人还是个小白,对php等技术了解并不深,基本上都是参照别的大佬的文章整合起来,并踩了三天坑才成功的.不管怎样,可以访问成功了就甚是欣慰.

Nginx安装

1.我的nginx安装是直接通过源码包编译安装的,如需使用APT源安装可以参考这篇博客(源码安装我也是参考的这里,下面把大佬的文章又敲了一遍,加深记忆),感谢大佬的无私奉献!

https://www.cnblogs.com/EasonJim/p/7806879.html

nginx官方下载页面:http://nginx.org/en/download.html

configure配置文件详解:http://nginx.org/en/docs/configure.html

 

2.安装gcc g++的依赖库

sudo apt-get install build-essential

sudo apt-get install libtool

 

3.安装pcre依赖库

sudo apt-get update

sudo apt-get install libpcre3 libpcre3-dev

 

4.安装zlib依赖库

sudo apt-get install zlib1g-dev

 

5.安装SSL依赖库(16.04默认已经安装好了)

sudo apt-get install openssl

 

6.安装Nginx

#下载最新版本:

wget http://nginx.org/download/nginx-1.15.5.tar.gz

#解压

tar -zxvf nginx-1.15.5.tar.gz

#进入解压目录:

cd nginx-1.15.5

#配置(放在/usr/local文件夹下)

sudo ./configure --prefix=/usr/local/nginx

#编译

sudo make

#安装

sudo make install

#启动

sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

注意:-c 指定配置文件的路径,不加的话,nginx会自动加载默认路径的配置文件,可以通过-h查看帮助命令。

#查看进程:

ps -ef | grep nginx

#配置软连接

sudo ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx

配置完成后就可以直接使用sudo nginx启动

如需关闭nginx,可使用

sudo pkill -9 nginx

#配置开机启动服务

在/etc/init.d/下创建nginx文件,sudo vim /etc/init.d/nginx,内容如下:

#!/bin/sh



### BEGIN INIT INFO

# Provides: nginx

# Required-Start: $local_fs $remote_fs $network $syslog $named

# Required-Stop: $local_fs $remote_fs $network $syslog $named

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: starts the nginx web server

# Description: starts nginx using start-stop-daemon

### END INIT INFO



PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DAEMON=/usr/local/nginx/sbin/nginx

NAME=nginx

DESC=nginx



# Include nginx defaults if available

if [ -r /etc/default/nginx ]; then

. /etc/default/nginx

fi



STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}"



test -x $DAEMON || exit 0



. /lib/init/vars.sh

. /lib/lsb/init-functions



# Try to extract nginx pidfile

PID=$(cat /usr/local/nginx/conf/nginx.conf | grep -Ev '^\s*#' | awk 'BEGIN { RS="[;{}]" } { if ($1 == "pid") print $2 }' | head -n1)

if [ -z "$PID" ]; then

PID=/run/nginx.pid

fi



if [ -n "$ULIMIT" ]; then

# Set ulimit if it is set in /etc/default/nginx

ulimit $ULIMIT

fi



start_nginx() {

# Start the daemon/service

#

# Returns:

# 0 if daemon has been started

# 1 if daemon was already running

# 2 if daemon could not be started

start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON --test > /dev/null \

|| return 1

start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON -- \

$DAEMON_OPTS 2>/dev/null \

|| return 2

}



test_config() {

# Test the nginx configuration

$DAEMON -t $DAEMON_OPTS >/dev/null 2>&1

}



stop_nginx() {

# Stops the daemon/service

#

# Return

# 0 if daemon has been stopped

# 1 if daemon was already stopped

# 2 if daemon could not be stopped

# other if a failure occurred

start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $NAME

RETVAL="$?"

sleep 1

return "$RETVAL"

}



reload_nginx() {

# Function that sends a SIGHUP to the daemon/service

start-stop-daemon --stop --signal HUP --quiet --pidfile $PID --name $NAME

return 0

}



rotate_logs() {

# Rotate log files

start-stop-daemon --stop --signal USR1 --quiet --pidfile $PID --name $NAME

return 0

}



upgrade_nginx() {

# Online upgrade nginx executable

# http://nginx.org/en/docs/control.html

#

# Return

# 0 if nginx has been successfully upgraded

# 1 if nginx is not running

# 2 if the pid files were not created on time

# 3 if the old master could not be killed

if start-stop-daemon --stop --signal USR2 --quiet --pidfile $PID --name $NAME; then

# Wait for both old and new master to write their pid file

while [ ! -s "${PID}.oldbin" ] || [ ! -s "${PID}" ]; do

cnt=`expr $cnt + 1`

if [ $cnt -gt 10 ]; then

return 2

fi

sleep 1

done

# Everything is ready, gracefully stop the old master

if start-stop-daemon --stop --signal QUIT --quiet --pidfile "${PID}.oldbin" --name $NAME; then

return 0

else

return 3

fi

else

return 1

fi

}



case "$1" in

start)

log_daemon_msg "Starting $DESC" "$NAME"

start_nginx

case "$?" in

0|1) log_end_msg 0 ;;

2) log_end_msg 1 ;;

esac

;;

stop)

log_daemon_msg "Stopping $DESC" "$NAME"

stop_nginx

case "$?" in

0|1) log_end_msg 0 ;;

2) log_end_msg 1 ;;

esac

;;

restart)

log_daemon_msg "Restarting $DESC" "$NAME"



# Check configuration before stopping nginx

if ! test_config; then

log_end_msg 1 # Configuration error

exit $?

fi



stop_nginx

case "$?" in

0|1)

start_nginx

case "$?" in

0) log_end_msg 0 ;;

1) log_end_msg 1 ;; # Old process is still running

*) log_end_msg 1 ;; # Failed to start

esac

;;

*)

# Failed to stop

log_end_msg 1

;;

esac

;;

reload|force-reload)

log_daemon_msg "Reloading $DESC configuration" "$NAME"



# Check configuration before stopping nginx

#

# This is not entirely correct since the on-disk nginx binary

# may differ from the in-memory one, but that's not common.

# We prefer to check the configuration and return an error

# to the administrator.

if ! test_config; then

log_end_msg 1 # Configuration error

exit $?

fi



reload_nginx

log_end_msg $?

;;

configtest|testconfig)

log_daemon_msg "Testing $DESC configuration"

test_config

log_end_msg $?

;;

status)

status_of_proc -p $PID "$DAEMON" "$NAME" && exit 0 || exit $?

;;

upgrade)

log_daemon_msg "Upgrading binary" "$NAME"

upgrade_nginx

log_end_msg $?

;;

rotate)

log_daemon_msg "Re-opening $DESC log files" "$NAME"

rotate_logs

log_end_msg $?

;;

*)

echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest|rotate|upgrade}" >&2

exit 3

;;

esac

 

#设置服务脚本有执行权限

sudo chmod +x /etc/init.d/nginx

#注册服务

cd /etc/init.d/

sudo update-rc.d nginx defaults

#验证nginx是否安装成功

/usr/local/nginx/sbin/nginx -v

查看nginx版本

nginx默认端口为80,如果想要修改的话需修改配置文件nginx.conf

在/usr/local/nginx/conf/ 文件夹下,不同版本的nginx可能位置不同.

直接在浏览器中输入IP或域名,加端口号就可看到nginx的欢迎页

这里借张图

欢迎页

 

现在就可以开机自启动了,常用命令如下

sudo service nginx {start|stop|restart|reload|force-reload|status|configtest|rotate|upgrade}

sudo nginx

sudo pkill -9 nginx

 

参考:

https://www.cnblogs.com/EasonJim/p/7806879.html

http://www.linuxidc.com/Linux/2016-08/134080.htm

 

安装PHP5.6

因为对PHP不太了解,所以对别人的安装方法进行了参考,下面会放出参考的链接

 

1.添加PPA(Personal Package Archives)

sudo apt-get install python-software-properties software-properties-common

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

 

#新服务器上可能无法使用add-apt-repository命令,那么就需要安装下

sudo apt-get install software-properties-common python-software-properties

 

2.安装php5.6以及所需的一些扩展

sudo apt-get install php5.6-fpm php5.6-mysql php5.6-common php5.6-curl php5.6-cli php5.6-mcrypt php5.6-mbstring php5.6-dom

 

3.配置php5.6

打开php.ini配置文件:

sudo nano /etc/php/5.6/fpm/php.ini

找到cgi.fix_pathinfo选项,去掉注释,然后将值设置为0

cgi.fix_pathinfo = 0;

找到display_errors 把值设置为On

display_errors = On

 

修改nginx.conf文件

1.在http的server中增加php的配置

http{

listen 设置成要监听的端口号;

server_name 设置成自己的域名或IP;

root /var/www;



server{

location ~ \.php$ {

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_pass unix:/run/php/php5.6-fpm.sock;

fastcgi_index index.php;

include fastcgi_params;

}

}

}

 

2.关闭并重启nginx

sudo pkill -9 nginx

sudo nginx

 

下载XSS Platform

我是在网上找的别人的XSS平台源码,安全性也没有检测,大佬们也可以去Git上面去搜,自己修改更省心.

源码下载:链接: http://pan.baidu.com/s/1gfdUYiB

密码:efp1

1.解压到 /var/www/目录下

unzip XSS+Platform+.zip

2.修改config.php里面的数据库连接字段,包括数据库设置、URL配置以及显示设置

注册配置先设置为normal,在自己注册后再使用其他选项,

2.将xssplatform.sql导入mysql

#进入mysql数据库

mysql -u root -p

#输入密码

#创建xss数据库

CREATE DATABASE xss;

#进入xss数据库

use xss;

source /var/www/XSS/xssplatform.sql

#导入成功后执行以下命令

UPDATE oc_module SET code=REPLACE(code,'http://xsser.me','http://yourdomain/xss');

 

3.配置伪静态文件(.htaccess)

在网站的根目录下,新建文件.htaccess

cd /var/www/XSS

nano .htaccess

保存如下内容

rewrite "^/([0-9a-zA-Z]{6})$" /index.php?do=code&urlKey=$1 break;

rewrite "^/do/auth/(w+?)(/domain/([w.]+?))?$" /index.php?do=do&auth=$1&domain=$3 break;

rewrite "^/register/(.?)$" /index.php?do=register&key=$1 break;

rewrite "^/register-validate/(.?)$" /index.php?do=register&act=validate&key=$1 break;

rewrite "^/login$" /index.php?do=login break;

保存就好了

 

其它配置

上面的步骤都设置好了用浏览器访问:http:IP:端口号/XSS,nginx可能会报错,登录后台查看nginx的错误日志可以看到如下错误.

我就参考了此篇文章

https://www.cnblogs.com/zl0372/p/nginx_140725.html

进入到/etc/php/5.6/fpm/pool.d文件夹中

编辑www.conf文件,将以下的注释去掉

listen.owner = www-data

listen.group = www-data

listen.mode = 0660

然后重启php-fpm,nginx

sudo pkill -9 php-fpm

sudo /usr/sbin/php-fpm5.6 -R

sudo pkill -9 nginx

sudo nginx

 

这些做完了在用浏览器访问应该就可以看到这个页面了

 

点击注册,邀请码随便填,可以成功登陆后就在进到mysql中,把oc_user表中自己账号的adminLevel字段值设为1.

先查看下账号id

select * from oc_user\G;

use xss

update oc_user SET adminLevel=1 where id=1;

 

最后别忘了把XSS文件夹下的注册配置改为invite

然后就大功告成了.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值