1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

feat(waf): 增加概览页 (#4060)

This commit is contained in:
zhengkunwang 2024-03-04 16:53:06 +08:00 committed by GitHub
parent d42df7184c
commit c49c4b7863
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 59573 additions and 158 deletions

View File

@ -0,0 +1,36 @@
{
"Anhui": "安徽",
"Beijing": "北京",
"Fujian": "福建",
"Gansu": "甘肃",
"Guangdong": "广东",
"Guangxi": "广西",
"Guizhou": "贵州",
"Hainan": "海南",
"Hebei": "河北",
"Henan": "河南",
"Heilongjiang": "黑龙江",
"Hubei": "湖北",
"Hunan": "湖南",
"Jilin": "吉林",
"Jiangsu": "江苏",
"Jiangxi": "江西",
"Liaoning": "辽宁",
"Inner Mongolia": "内蒙古",
"Ningxia": "宁夏",
"Qinghai": "青海",
"Shandong": "山东",
"Shanxi": "山西",
"Shaanxi": "陕西",
"Shanghai": "上海",
"Sichuan": "四川",
"Tianjin": "天津",
"Tibet": "西藏",
"Xinjiang": "新疆",
"Yunnan": "云南",
"Zhejiang": "浙江",
"Chongqing": "重庆",
"HongKong": "香港",
"Macao": "澳门",
"Taiwan": "台湾"
}

File diff suppressed because it is too large Load Diff

View File

@ -1,224 +1,192 @@
{
"Afghanistan": "阿富汗",
"Singapore": "新加坡",
"Angola": "安哥拉",
"Albania": "阿尔巴尼亚",
"United Arab Emirates": "阿联酋",
"Algeria": "阿尔及利亚",
"Angola": "安哥拉",
"Argentina": "阿根廷",
"Armenia": "亚美尼亚",
"French Southern and Antarctic Lands": "法属南半球和南极领地",
"Australia": "澳大利亚",
"Austria": "奥地利",
"Azerbaijan": "阿塞拜疆",
"Burundi": "布隆迪",
"Belgium": "比利时",
"Benin": "贝宁",
"Burkina Faso": "布基纳法索",
"Bahamas": "巴哈马",
"Bahrain": "巴林",
"Bangladesh": "孟加拉国",
"Bulgaria": "保加利亚",
"The Bahamas": "巴哈马",
"Bosnia and Herzegovina": "波斯尼亚和黑塞哥维那",
"Belarus": "白俄罗斯",
"Belgium": "比利时",
"Belize": "伯利兹",
"Bermuda": "百慕大",
"Bolivia": "玻利维亚",
"Brazil": "巴西",
"Brunei": "文莱",
"Benin": "贝宁",
"Bhutan": "不丹",
"Bolivia": "玻利维亚",
"Bosnia and Herz.": "波斯尼亚和黑塞哥维那",
"Botswana": "博茨瓦纳",
"Central African Republic": "中非共和国",
"Brazil": "巴西",
"British Virgin Islands": "英属维京群岛",
"Brunei": "文莱",
"Bulgaria": "保加利亚",
"Burkina Faso": "布基纳法索",
"Burundi": "布隆迪",
"Cambodia": "柬埔寨",
"Cameroon": "喀麦隆",
"Canada": "加拿大",
"Switzerland": "瑞士",
"Cape Verde": "佛得角",
"Cayman Islands": "开曼群岛",
"Central African Rep.": "中非共和国",
"Chad": "乍得",
"Chile": "智利",
"China": "中国",
"Ivory Coast": "象牙海岸",
"Cameroon": "喀麦隆",
"Democratic Republic of the Congo": "刚果民主共和国",
"Republic of the Congo": "刚果共和国",
"Colombia": "哥伦比亚",
"Comoros": "科摩罗",
"Congo": "刚果",
"Costa Rica": "哥斯达黎加",
"Croatia": "克罗地亚",
"Cuba": "古巴",
"Northern Cyprus": "北塞浦路斯",
"Cyprus": "塞浦路斯",
"Czech Republic": "捷克共和国",
"Germany": "德国",
"Djibouti": "吉布提",
"Czech Rep.": "捷克共和国",
"Côte d'Ivoire": "科特迪瓦",
"Dem. Rep. Congo": "刚果民主共和国",
"Dem. Rep. Korea": "朝鲜",
"Denmark": "丹麦",
"Dominican Republic": "多明尼加共和国",
"Algeria": "阿尔及利亚",
"Djibouti": "吉布提",
"Dominican Rep.": "多米尼加共和国",
"Ecuador": "厄瓜多尔",
"Egypt": "埃及",
"El Salvador": "萨尔瓦多",
"Equatorial Guinea": "赤道几内亚",
"Eritrea": "厄立特里亚",
"Spain": "西班牙",
"Estonia": "爱沙尼亚",
"Ethiopia": "埃塞俄比亚",
"Falkland Is.": "福克兰群岛",
"Fiji": "斐济",
"Finland": "芬兰",
"Fiji": "斐",
"Falkland Islands": "福克兰群岛",
"Fr. S. Antarctic Lands": "所罗门群岛",
"France": "法国",
"Gabon": "加蓬",
"United Kingdom": "英国",
"Georgia": "格鲁吉亚",
"Ghana": "加纳",
"Guinea": "几内亚",
"Gambia": "冈比亚",
"Guinea Bissau": "几内亚比绍",
"Georgia": "格鲁吉亚",
"Germany": "德国",
"Ghana": "加纳",
"Greece": "希腊",
"Greenland": "格陵兰",
"Guatemala": "危地马拉",
"French Guiana": "法属圭亚那",
"Guinea": "几内亚",
"Guinea-Bissau": "几内亚比绍",
"Guyana": "圭亚那",
"Honduras": "洪都拉斯",
"Croatia": "克罗地亚",
"Haiti": "海地",
"Honduras": "洪都拉斯",
"Hungary": "匈牙利",
"Indonesia": "印度尼西亚",
"Iceland": "冰岛",
"India": "印度",
"Ireland": "爱尔兰",
"Indonesia": "印度尼西亚",
"Iran": "伊朗",
"Iraq": "伊拉克",
"Iceland": "冰岛",
"Ireland": "爱尔兰",
"Isle of Man": "马恩岛",
"Israel": "以色列",
"Italy": "意大利",
"Jamaica": "牙买加",
"Jordan": "约旦",
"Japan": "日本",
"Jordan": "约旦",
"Kazakhstan": "哈萨克斯坦",
"Kenya": "肯尼亚",
"Kyrgyzstan": "吉尔吉斯斯坦",
"Cambodia": "柬埔寨",
"Kosovo": "科索沃",
"Korea": "韩国",
"Kuwait": "科威特",
"Laos": "老挝",
"Kyrgyzstan": "吉尔吉斯斯坦",
"Lao PDR": "老挝",
"Latvia": "拉脱维亚",
"Lebanon": "黎巴嫩",
"Lesotho": "莱索托",
"Liberia": "利比里亚",
"Libya": "利比亚",
"Sri Lanka": "斯里兰卡",
"Lesotho": "莱索托",
"Lithuania": "立陶宛",
"Luxembourg": "卢森堡",
"Latvia": "拉脱维亚",
"Morocco": "摩洛哥",
"Moldova": "摩尔多瓦",
"Madagascar": "马达加斯加",
"Mexico": "墨西哥",
"Macedonia": "马其顿",
"Mali": "马里",
"Myanmar": "缅甸",
"Montenegro": "黑山",
"Mongolia": "蒙古",
"Mozambique": "莫桑比克",
"Mauritania": "毛里塔尼亚",
"Madagascar": "马达加斯加",
"Malawi": "马拉维",
"Malaysia": "马来西亚",
"Maldives": "马尔代夫",
"Mali": "马里",
"Malta": "马耳他",
"Mauritania": "毛利塔尼亚",
"Mauritius": "毛里求斯",
"Mexico": "墨西哥",
"Moldova": "摩尔多瓦",
"Monaco": "摩纳哥",
"Mongolia": "蒙古",
"Montenegro": "黑山共和国",
"Morocco": "摩洛哥",
"Mozambique": "莫桑比克",
"Myanmar": "缅甸",
"Namibia": "纳米比亚",
"Nepal": "尼泊尔",
"Netherlands": "荷兰",
"New Caledonia": "新喀里多尼亚",
"New Zealand": "新西兰",
"Nicaragua": "尼加拉瓜",
"Niger": "尼日尔",
"Nigeria": "尼日利亚",
"Nicaragua": "尼加拉瓜",
"Netherlands": "荷兰",
"Norway": "挪威",
"Nepal": "尼泊尔",
"New Zealand": "新西兰",
"Oman": "阿曼",
"Pakistan": "巴基斯坦",
"Panama": "巴拿马",
"Papua New Guinea": "巴布亚新几内亚",
"Paraguay": "巴拉圭",
"Peru": "秘鲁",
"Philippines": "菲律宾",
"Papua New Guinea": "巴布亚新几内亚",
"Poland": "波兰",
"Puerto Rico": "波多黎各",
"North Korea": "北朝鲜",
"Portugal": "葡萄牙",
"Paraguay": "巴拉圭",
"Puerto Rico": "波多黎各",
"Qatar": "卡塔尔",
"Reunion": "留尼旺",
"Romania": "罗马尼亚",
"Russia": "俄罗斯",
"Rwanda": "卢旺达",
"Western Sahara": "西撒哈拉",
"S. Geo. and S. Sandw. Is.": "南乔治亚和南桑威奇群岛",
"S. Sudan": "南苏丹",
"San Marino": "圣马力诺",
"Saudi Arabia": "沙特阿拉伯",
"Sudan": "苏丹",
"South Sudan": "南苏丹",
"Senegal": "塞内加尔",
"Solomon Islands": "所罗门群岛",
"Serbia": "塞尔维亚",
"Sierra Leone": "塞拉利昂",
"El Salvador": "萨尔瓦多",
"Somaliland": "索马里兰",
"Somalia": "索马里",
"Republic of Serbia": "塞尔维亚",
"Suriname": "苏里南",
"Singapore": "新加坡",
"Slovakia": "斯洛伐克",
"Slovenia": "斯洛文尼亚",
"Sweden": "瑞典",
"Solomon Is.": "所罗门群岛",
"Somalia": "索马里",
"South Africa": "南非",
"Spain": "西班牙",
"Sri Lanka": "斯里兰卡",
"Sudan": "苏丹",
"Suriname": "苏里南",
"Swaziland": "斯威士兰",
"Sweden": "瑞典",
"Switzerland": "瑞士",
"Syria": "叙利亚",
"Chad": "乍得",
"Togo": "多哥",
"Thailand": "泰国",
"Taiwan": "中国台湾",
"Tajikistan": "塔吉克斯坦",
"Turkmenistan": "土库曼斯坦",
"East Timor": "东帝汶",
"Trinidad and Tobago": "特里尼达和多巴哥",
"Tanzania": "坦桑尼亚",
"Thailand": "泰国",
"Togo": "多哥",
"Tonga": "汤加",
"Trinidad and Tobago": "特立尼达和多巴哥",
"Tunisia": "突尼斯",
"Turkey": "土耳其",
"United Republic of Tanzania": "坦桑尼亚",
"Turkmenistan": "土库曼斯坦",
"U.S. Virgin Islands": "美属维尔京群岛",
"Uganda": "乌干达",
"Ukraine": "乌克兰",
"Uruguay": "乌拉圭",
"United Arab Emirates": "阿拉伯联合酋长国",
"United Kingdom": "英国",
"United States": "美国",
"Uruguay": "乌拉圭",
"Uzbekistan": "乌兹别克斯坦",
"Vanuatu": "瓦努阿图",
"Vatican City": "梵蒂冈城",
"Venezuela": "委内瑞拉",
"Vietnam": "越南",
"Vanuatu": "瓦努阿图",
"West Bank": "西岸",
"Yemen": "也门",
"South Africa": "南非",
"Zambia": "赞比亚",
"Korea": "韩国",
"Tanzania": "坦桑尼亚",
"Zimbabwe": "津巴布韦",
"Congo": "刚果",
"Central African Rep.": "中非",
"Serbia": "塞尔维亚",
"Bosnia and Herz.": "波斯尼亚和黑塞哥维那",
"Czech Rep.": "捷克",
"W. Sahara": "西撒哈拉",
"Lao PDR": "老挝",
"Dem.Rep.Korea": "朝鲜",
"Falkland Is.": "福克兰群岛",
"Timor-Leste": "东帝汶",
"Solomon Is.": "所罗门群岛",
"Palestine": "巴勒斯坦",
"N. Cyprus": "北塞浦路斯",
"Aland": "奥兰群岛",
"Fr. S. Antarctic Lands": "法属南半球和南极陆地",
"Mauritius": "毛里求斯",
"Comoros": "科摩罗",
"Eq. Guinea": "赤道几内亚",
"Guinea-Bissau": "几内亚比绍",
"Dominican Rep.": "多米尼加",
"Saint Lucia": "圣卢西亚",
"Dominica": "多米尼克",
"Antigua and Barb.": "安提瓜和巴布达",
"U.S. Virgin Is.": "美国原始岛屿",
"Montserrat": "蒙塞拉特",
"Grenada": "格林纳达",
"Barbados": "巴巴多斯",
"Samoa": "萨摩亚",
"Bahamas": "巴哈马",
"Cayman Is.": "开曼群岛",
"Faeroe Is.": "法罗群岛",
"IsIe of Man": "马恩岛",
"Malta": "马耳他共和国",
"Jersey": "泽西",
"Cape Verde": "佛得角共和国",
"Turks and Caicos Is.": "特克斯和凯科斯群岛",
"St. Vin. and Gren.": "圣文森特和格林纳丁斯",
"Singapore Rep.": "新加坡",
"Côte d'Ivoire": "科特迪瓦",
"Siachen Glacier": "锡亚琴冰川",
"Br. Indian Ocean Ter.": "英属印度洋领土",
"Dem. Rep. Congo": "刚果民主共和国",
"Dem. Rep. Korea": "朝鲜",
"S. Sudan": "南苏丹"
"Yemen": "也门",
"Yugoslavia": "南斯拉夫",
"Zaire": "扎伊尔",
"Zambia": "赞比亚",
"Zimbabwe": "津巴布韦"
}

File diff suppressed because one or more lines are too long

View File

@ -2143,13 +2143,29 @@ const message = {
manage: 'Management',
},
xpack: {
name: 'X-Pack',
name: 'Professional Edition',
waf: {
name: 'WAF',
blackWhite: 'Black and White List',
blackWhite: 'black and white list',
globalSetting: 'Global Setting',
websiteSetting: 'Website Setting',
blockRecords: 'Block Records',
websiteSetting: 'Website Settings',
blockRecords: 'Block records',
world: 'world',
china: 'China',
intercept: 'interception',
request: 'request',
count4xx: '4xx quantity',
count5xx: '5xx quantity',
todayStatus: 'Today status',
reqMap: 'Request map (30 days)',
resource: 'source',
count: 'Quantity',
hight: 'high',
low: 'low',
reqCount: 'Number of requests',
interceptCount: 'Interception number',
requestTrends: 'Request Trends (7 days)',
interceptTrends: 'Intercept Trends (7 days)',
},
monitor: {
name: 'Website Monitoring',

View File

@ -2005,13 +2005,29 @@ const message = {
manage: '管理',
},
xpack: {
name: 'X-Pack',
name: '專業版',
waf: {
name: 'WAF',
blackWhite: '黑白名單',
globalSetting: '局設置',
websiteSetting: '網站設',
globalSetting: '域設定',
websiteSetting: '網站設',
blockRecords: '封鎖記錄',
world: '世界',
china: '中國',
intercept: '攔截',
request: '請求',
count4xx: '4xx 數量',
count5xx: '5xx 數量',
todayStatus: '今日狀態',
reqMap: '請求地圖30',
resource: '來源',
count: '數量',
hight: '高',
low: '低',
reqCount: '請求數',
interceptCount: '攔截數',
requestTrends: '請求趨勢7',
interceptTrends: '攔截趨勢7',
},
monitor: {
name: '網站監控',

View File

@ -2006,13 +2006,29 @@ const message = {
},
},
xpack: {
name: 'X-Pack',
name: '专业版',
waf: {
name: 'WAF',
blackWhite: '黑白名单',
globalSetting: '全局设置',
websiteSetting: '网站设置',
blockRecords: '封锁记录',
world: '世界',
china: '中国',
intercept: '拦截',
request: '请求',
count4xx: '4xx 数量',
count5xx: '5xx 数量',
todayStatus: '今日状态',
reqMap: '请求地图30',
resource: '来源',
count: '数量',
hight: '高',
low: '低',
reqCount: '请求数',
interceptCount: '拦截数',
requestTrends: '请求趋势7',
interceptTrends: '拦截趋势7',
},
monitor: {
name: '网站监控',

View File

@ -28,7 +28,7 @@ local function check_table(table_name,wafdb)
return rows > 0
end
function _M.init_db()
function _M.init()
local ok, sqlite3 = pcall(function()
return require "lsqlite3"
end)

View File

@ -1,9 +1,10 @@
local db = require "db"
local config = require "config"
local geoip = require "geoip"
config.load_config_file()
db.init_db()
db.init()

View File

@ -1,7 +1,7 @@
local redis_util = require "redis_util"
local action = require "action"
local cc = require "cc"
local fileUtils = require "file"
local file_utils = require "file"
local ck = require "resty.cookie"
local geo = require "geoip"
local libinjection = require "resty.libinjection"
@ -154,7 +154,7 @@ local function get_request_body()
if not body_data then
local body_file = ngx.req.get_body_file()
if body_file then
body_data = fileUtils.read_file2string(body_file, true)
body_data = file_utils.read_file2string(body_file, true)
end
end
return body_data

View File

@ -8,7 +8,7 @@ local upper_str = string.upper
local tonumber = tonumber
local pairs = pairs
local function write_req_Log(wafdb,attack)
local function write_req_log(wafdb,attack)
local rule_table = nil
local action = ""
local rule = nil
@ -73,7 +73,11 @@ local function write_req_Log(wafdb,attack)
for k, v in pairs(headers) do
local value = ""
if v then
value = v
if type(v) == "table" then
value = table.concat(v, ",")
else
value = v
end
end
logs_str = logs_str .. upper_str(k) .. ": " .. value .. "\n"
end
@ -214,6 +218,6 @@ if config.is_waf_on() then
local wafdb = utils.get_wafdb(config.waf_db_path)
if wafdb ~= nil then
count_req_status(wafdb,is_attack)
write_req_Log(wafdb,is_attack)
write_req_log(wafdb,is_attack)
end
end

View File

@ -1,6 +1,6 @@
local geoip = require "geoip"
local lib = require "lib"
local fileUtils = require "file"
local file_utils = require "file"
local config = require "config"
local cc = require "cc"
local utils = require "utils"
@ -11,7 +11,7 @@ local sub_str = string.sub
local find_str = string.find
local split_str = utils.split
local encode = cjson.encode
local read_file2table = fileUtils.read_file2table
local read_file2table = file_utils.read_file2table
local tonumber = tonumber
local date = os.date
local format_str = string.format
@ -64,9 +64,10 @@ local function init()
if not ua then
ua = ""
end
ngx.ctx.ua = ua
geoip.init()
geoip.init()
ngx.ctx.ua = ua
ngx.ctx.geoip = get_geo_ip(ip)
local msg = "访问 IP " .. ip
@ -143,10 +144,17 @@ local function waf_api()
end
end
ngx.log(ngx.ERR,"access waf")
if config.is_waf_on() then
init()
waf_api()
if ngx.ctx.website_key == "unknown" then
ngx.exit(403)
return
end
if lib.is_white_ip() then
return true
end
@ -174,5 +182,4 @@ if config.is_waf_on() then
lib.cookie_check()
lib.post_check()
lib.header_check()
end