这小节应该在之前写,但是这里备注一下:
其实无非就两个方法:
local args = ngx.req.get_post_args()
local args = ngx.req.get_uri_args()
然后使用args.参数KEY 就可以获取变量值了
这小节应该在之前写,但是这里备注一下:
其实无非就两个方法:
local args = ngx.req.get_post_args()
local args = ngx.req.get_uri_args()
然后使用args.参数KEY 就可以获取变量值了
同样的看redis组件
https://github.com/openresty/lua-resty-redis
按照实例添加redis.conf
worker_processes 1; error_log logs/error.log; events { worker_connections 1024; } http { server { listen 8091; location / { default_type text/html; content_by_lua_block { local redis = require "resty.redis" local red = redis:new() red:set_timeout(1000) local ok,err = red:connect("127.0.0.1", 6379) if not ok then ngx.say("fail to connent", err) return end local res,err = red:get("lua") if not res then ngx.say("failed to get lua", err) return end ngx.say(res) } } } }
启动redis.conf配置
../nginx/sbin/nginx -p `pwd`/ -c conf/redis.conf
访问localhost:8091 获取了key为lua的数据,使用起来非常简单。
openresty操作数据库本质上调用了lua-resty-mysql 组件
具体参照git:https://github.com/openresty/lua-resty-mysql#table-of-contents
同样的在/usr/local/openresty/work/conf/ 文件夹下添加新的文件mysql.conf
内容如下:
worker_processes 1; error_log logs/error.log; events { worker_connections 1024; } http { server { listen 8089; server_name localhost; location / { content_by_lua ' local arg = ngx.req.get_uri_args() local mysql = require "resty.mysql" local db, err = mysql:new() if not db then ngx.say("failed to instantiate mysql: ", err) return end db:set_timeout(1000) -- 1 sec local ok, err, errcode, sqlstate = db:connect{ host = "127.0.0.1", port = 3306, database = "test", user = "xxxx", password = "xxxxxxx", max_packet_size = 1024 * 1024 } if not ok then ngx.say("failed to connect: ", err, ": ", errcode, " ", sqlstate) return end --ngx.say("connected to mysql.") local id = tonumber(arg.id) queryStr = "select goods_id,goods_name from goods_test where goods_id ="..id --ngx.say(queryStr) res, err, errcode, sqlstate = --db:query("select * from goods_test order by goods_id asc", 10) db:query(queryStr) if not res then ngx.say("bad result: ", err, ": ", errcode, ": ", sqlstate, ".") return end local cjson = require "cjson" ngx.say("result: ", cjson.encode(res)) '; } } }
是不是很简单,然后../nginx/sbin/nginx -p `pwd`/ -s reload -c conf/mysql.conf
重新加载配置文件,这样访问localhost:8089?id=1 就可以筛选数据库中主键ID=1的数据了。应该有mysql注入问题,所以参数全部转化为int类型,基本的网络安全意识不能没有。
首先推荐官网:http://openresty.org/en/
一,安装openresty包
1,安装依赖
yum install perl dos2unix
yum install pcre-devel openssl-devel gc-c++
wget https://openresty.org/download/openresty-1.11.2.1.tar.gz
解压tar zxvf openresty-1.11.2.1
./configure
gmake
gmake install
安装完成
默认的路径是/usr/local/openresty/
二 hello world 程序
参考http://openresty.org/cn/getting-started.html
We first create a separate directory for our experiments. You can use an arbitrary directory. Here for simplicity, we just use~/work
:
mkdir ~/work
cd ~/work
mkdir logs/ conf/
Note that we’ve also created the logs/
directory for logging files and conf/
for our config files.
Create a simple plain text file named conf/nginx.conf
with the following contents in it:
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8088;
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}
If you’re familiar with Nginx configuration, it should look very familiar to you. OpenResty is just an enhanced version of Nginxby means of addon modules anyway. You can take advantage of all the exisitng goodies in the Nginx world.
Assuming you have installed OpenResty into/usr/local/openresty
(this is the default)
Then we start the nginx server with our config file this way:
/usr/local/openresty/sbin/nginx -p `pwd`/ -c conf/nginx.conf
-p 标识的是
-p prefix : set prefix path (default: /usr/local/openresty/nginx/) 路径
-c filename : set configuration file (default: conf/nginx.conf) 配置
Error messages will go to the stderr device or the default error log files logs/error.log
in the current working directory.
We can use curl to access our new web service that says HelloWorld:
curl http://localhost:8088/
If everything is okay, we should get the output
<p>hello, world</p>
ab 压测一下
ab -c 10 -n 100 http://localhost:8088/
在单核阿里云的配置下:
Requests per second: 240.93 [#/sec] (mean) 还算比较高的
未完待续。。。。
最近使用了sqlmap进行了简单的操作。现在先说明sqlmap的一些参数:
举例
python sqlmap.py -u “http://www.xxx.com?id=1” –level=5 –dbs
会使用最高优获取数据库表
sqlmap的下载文件:https://pan.baidu.com/s/1dFmhV2L
做了一个简单的公众号,输入车牌号+密码 分享密码;只输入车牌号 获取密码。
理论上可以分享一切KEY=>VALUE格式的数据。
平台自己做着玩,不负法律责任,如有要求 可以下掉。