| Line 23... |
Line 23... |
| 23 |
*/
|
23 |
*/
|
| 24 |
namespace qbpwcf;
|
24 |
namespace qbpwcf;
|
| 25 |
|
25 |
|
| 26 |
/*
|
26 |
/*
|
| 27 |
類別說明:
|
27 |
類別說明:
|
| 28 |
跟網頁安全性有關的類別.
|
28 |
跟網頁、資訊安全性有關的類別.
|
| 29 |
備註:
|
29 |
備註:
|
| 30 |
無.
|
30 |
無.
|
| 31 |
*/
|
31 |
*/
|
| 32 |
class security{
|
32 |
class security{
|
| 33 |
|
33 |
|
| Line 1283... |
Line 1283... |
| 1283 |
|
1283 |
|
| 1284 |
#回傳結果
|
1284 |
#回傳結果
|
| 1285 |
return $result;
|
1285 |
return $result;
|
| 1286 |
|
1286 |
|
| 1287 |
}#function encodePHP end
|
1287 |
}#function encodePHP end
|
| - |
|
1288 |
|
| - |
|
1289 |
/*
|
| - |
|
1290 |
#函式說明:
|
| - |
|
1291 |
#檢查 apache http(s) log 中疑似攻擊的記錄.
|
| - |
|
1292 |
#回傳結果:
|
| - |
|
1293 |
#$result["status"],字串,執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
1294 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
1295 |
#$result["function"],字串,當前執行的函式名稱.
|
| - |
|
1296 |
#$result["content"],陣列,攻擊記錄資訊,每個元素為陣列key為"ip"者為攻擊者的ip;key為info者為其資訊陣列,其key為"log"者代表log的行內容;key為"time"者代表時間點;key為ip者代表ip.
|
| - |
|
1297 |
#必填參數:
|
| - |
|
1298 |
#無.
|
| - |
|
1299 |
#可省略參數:
|
| - |
|
1300 |
#$conf["logPath"],http log的路徑,預設為"/var/log/httpd".
|
| - |
|
1301 |
#$conf["logPath"]="/var/log/httpd";
|
| - |
|
1302 |
#$conf["https"],字串,是否為要查https的log,預設為"false",代表為http.
|
| - |
|
1303 |
#$conf["https"]="false";
|
| - |
|
1304 |
#參考資料:
|
| - |
|
1305 |
#無.
|
| - |
|
1306 |
#備註:
|
| - |
|
1307 |
#目前僅支援 apache 提供的 http(s) 服務.
|
| - |
|
1308 |
#攻擊者的定義包含http回應的code為4開頭或用戶使用 HTTP/1.0 協定或用戶使用 CONNECT method,且時間間隔不超過1秒鐘,次數達到3次.
|
| - |
|
1309 |
*/
|
| - |
|
1310 |
public static function checkHttpAttackLog(&$conf){
|
| - |
|
1311 |
|
| - |
|
1312 |
#初始化要回傳的結果
|
| - |
|
1313 |
$result=array();
|
| - |
|
1314 |
|
| - |
|
1315 |
#取得當前執行的函數名稱
|
| - |
|
1316 |
$result["function"]=__FUNCTION__;
|
| - |
|
1317 |
|
| - |
|
1318 |
#取得參數
|
| - |
|
1319 |
$result["argu"]=$conf;
|
| - |
|
1320 |
|
| - |
|
1321 |
#如果 $conf 不為陣列
|
| - |
|
1322 |
if(gettype($conf)!="array"){
|
| - |
|
1323 |
|
| - |
|
1324 |
#設置執行失敗
|
| - |
|
1325 |
$result["status"]="false";
|
| - |
|
1326 |
|
| - |
|
1327 |
#設置執行錯誤訊息
|
| - |
|
1328 |
$result["error"][]="\$conf變數須為陣列形態";
|
| - |
|
1329 |
|
| - |
|
1330 |
#如果傳入的參數為 null
|
| - |
|
1331 |
if(is_null($conf)){
|
| - |
|
1332 |
|
| - |
|
1333 |
#設置執行錯誤訊息
|
| - |
|
1334 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
| - |
|
1335 |
|
| - |
|
1336 |
}#if end
|
| - |
|
1337 |
|
| - |
|
1338 |
#回傳結果
|
| - |
|
1339 |
return $result;
|
| - |
|
1340 |
|
| - |
|
1341 |
}#if end
|
| - |
|
1342 |
|
| - |
|
1343 |
#函式說明:
|
| - |
|
1344 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
|
| - |
|
1345 |
#回傳結果:
|
| - |
|
1346 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
1347 |
#$result["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
1348 |
#$result["simpleError"],簡單表示的錯誤訊息.
|
| - |
|
1349 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
1350 |
#$result["argu"],設置給予的參數.
|
| - |
|
1351 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
| - |
|
1352 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
| - |
|
1353 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
| - |
|
1354 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
| - |
|
1355 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
| - |
|
1356 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
| - |
|
1357 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
| - |
|
1358 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
| - |
|
1359 |
#必填參數:
|
| - |
|
1360 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
| - |
|
1361 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
| - |
|
1362 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
| - |
|
1363 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
| - |
|
1364 |
#可省略參數:
|
| - |
|
1365 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
| - |
|
1366 |
#$conf["mustBeFilledVariableName"]=array();
|
| - |
|
1367 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
|
| - |
|
1368 |
#$conf["mustBeFilledVariableType"]=array();
|
| - |
|
1369 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
| - |
|
1370 |
#$conf["canBeEmptyString"]="false";
|
| - |
|
1371 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
| - |
|
1372 |
#$conf["canNotBeEmpty"]=array();
|
| - |
|
1373 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
| - |
|
1374 |
#$conf["canBeEmpty"]=array();
|
| - |
|
1375 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
| - |
|
1376 |
$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("logPath","https");
|
| - |
|
1377 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
| - |
|
1378 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("logPath","https");
|
| - |
|
1379 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| - |
|
1380 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
|
| - |
|
1381 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
| - |
|
1382 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("/var/log/httpd","false");
|
| - |
|
1383 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
| - |
|
1384 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
| - |
|
1385 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
| - |
|
1386 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
| - |
|
1387 |
#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
|
| - |
|
1388 |
#$conf["disallowAllSkipableVarNotExist"]="";
|
| - |
|
1389 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
| - |
|
1390 |
#$conf["arrayCountEqualCheck"][]=array();
|
| - |
|
1391 |
#參考資料:
|
| - |
|
1392 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
| - |
|
1393 |
#備註:
|
| - |
|
1394 |
#無.
|
| - |
|
1395 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
| - |
|
1396 |
unset($conf["variableCheck::checkArguments"]);
|
| - |
|
1397 |
|
| - |
|
1398 |
#預設為http的log
|
| - |
|
1399 |
$logFile="access_log";
|
| - |
|
1400 |
|
| - |
|
1401 |
#如果 https 為 "true"
|
| - |
|
1402 |
if($conf["https"]==="true"){
|
| - |
|
1403 |
|
| - |
|
1404 |
#設置為 https 的 log
|
| - |
|
1405 |
$logFile="ssl_access_log";
|
| - |
|
1406 |
|
| - |
|
1407 |
}#if end
|
| - |
|
1408 |
|
| - |
|
1409 |
#取得 http 存取記錄的 log
|
| - |
|
1410 |
#函式說明:
|
| - |
|
1411 |
#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
|
| - |
|
1412 |
#回傳的變數說明:
|
| - |
|
1413 |
#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
|
| - |
|
1414 |
#$result["error"],錯誤訊息提示.
|
| - |
|
1415 |
#$result["warning"],警告訊息.
|
| - |
|
1416 |
#$result["function"],當前執行的函數名稱.
|
| - |
|
1417 |
#$result["fileContent"],爲檔案的內容陣列.
|
| - |
|
1418 |
#$result["lineCount"],爲檔案內容總共的行數.
|
| - |
|
1419 |
#$result["fullContent"],為檔案的完整內容.
|
| - |
|
1420 |
#$result["base64dataOnly"],檔案的base64data.
|
| - |
|
1421 |
#$result["base64data"],為在網頁上給予src參數的數值.
|
| - |
|
1422 |
#$result["mimeType"],為檔案的mime type.
|
| - |
|
1423 |
#必填參數:
|
| - |
|
1424 |
#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
|
| - |
|
1425 |
$conf["fileAccess::getFileContent"]["filePositionAndName"]=$conf["logPath"]."/".$logFile;
|
| - |
|
1426 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
| - |
|
1427 |
$conf["fileAccess::getFileContent"]["fileArgu"]=__FILE__;
|
| - |
|
1428 |
#可省略參數:
|
| - |
|
1429 |
#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
|
| - |
|
1430 |
#$conf["web"]="true";
|
| - |
|
1431 |
#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
|
| - |
|
1432 |
#$conf["createIfnotExist"]="false";
|
| - |
|
1433 |
#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
|
| - |
|
1434 |
#$conf["autoDeleteSpaceOnEachLineStart"]="false";
|
| - |
|
1435 |
#參考資料:
|
| - |
|
1436 |
#file(),取得檔案內容的行數.
|
| - |
|
1437 |
#file=>http:#php.net/manual/en/function.file.php
|
| - |
|
1438 |
#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
|
| - |
|
1439 |
#filesize=>http://php.net/manual/en/function.filesize.php
|
| - |
|
1440 |
#參考資料:
|
| - |
|
1441 |
#無.
|
| - |
|
1442 |
#備註:
|
| - |
|
1443 |
#無.
|
| - |
|
1444 |
$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
|
| - |
|
1445 |
unset($conf["fileAccess::getFileContent"]);
|
| - |
|
1446 |
|
| - |
|
1447 |
#如果執行失敗
|
| - |
|
1448 |
if($getFileContent["status"]==="false"){
|
| - |
|
1449 |
|
| - |
|
1450 |
#設置執行失敗
|
| - |
|
1451 |
$result["status"]="false";
|
| - |
|
1452 |
|
| - |
|
1453 |
#設置錯誤訊息
|
| - |
|
1454 |
$result["error"]=$getFileContent;
|
| - |
|
1455 |
|
| - |
|
1456 |
#回傳結果
|
| - |
|
1457 |
return $result;
|
| - |
|
1458 |
|
| - |
|
1459 |
}#if end
|
| - |
|
1460 |
|
| - |
|
1461 |
/*
|
| - |
|
1462 |
http log 範例:
|
| - |
|
1463 |
36.149.205.198 - - [22/Jun/2026:15:49:21 +0800] "CONNECT api.ipapi.is:443 HTTP/1.1" 200 -
|
| - |
|
1464 |
36.149.205.198 - - [22/Jun/2026:15:49:24 +0800] "CONNECT ipwho.is:443 HTTP/1.1" 200 -
|
| - |
|
1465 |
36.149.205.198 - - [22/Jun/2026:15:49:18 +0800] "CONNECT push.services.mozilla.com:443 HTTP/1.1" 200 -
|
| - |
|
1466 |
120.48.6.159 - - [22/Jun/2026:15:49:20 +0800] "CONNECT ifconfig.me:443 HTTP/1.1" 200 -
|
| - |
|
1467 |
36.149.205.198 - - [22/Jun/2026:15:49:24 +0800] "CONNECT ipwho.is:443 HTTP/1.1" 200 -
|
| - |
|
1468 |
36.149.205.198 - - [22/Jun/2026:15:49:25 +0800] "CONNECT api.ipapi.is:443 HTTP/1.1" 200 -
|
| - |
|
1469 |
36.149.205.198 - - [22/Jun/2026:15:49:28 +0800] "CONNECT ipwho.is:443 HTTP/1.1" 200 -
|
| - |
|
1470 |
36.149.205.198 - - [22/Jun/2026:15:49:30 +0800] "CONNECT nexus.officeapps.live.com:443 HTTP/1.1" 200 -
|
| - |
|
1471 |
172.238.244.28 - - [22/Jun/2026:15:49:31 +0800] "GET / HTTP/1.0" 400 402
|
| - |
|
1472 |
36.149.205.198 - - [22/Jun/2026:15:49:29 +0800] "CONNECT api.ipapi.is:443 HTTP/1.1" 200 -
|
| - |
|
1473 |
36.149.205.198 - - [22/Jun/2026:15:49:33 +0800] "CONNECT qaz23.com:2869 HTTP/1.1" 403 353
|
| - |
|
1474 |
36.149.205.198 - - [22/Jun/2026:15:49:34 +0800] "CONNECT qaz23.com:2869 HTTP/1.1" 403 353
|
| - |
|
1475 |
*/
|
| - |
|
1476 |
|
| - |
|
1477 |
#初始化給予 search::getMatchFormatsStrings 使用的 formats 參數
|
| - |
|
1478 |
$formatsParamsOfsearchGetMatchFormatsStrings=array();
|
| - |
|
1479 |
$formatsParamsOfsearchGetMatchFormatsStrings[]="\${ip} \${doNotNeed} [\${day}/\${month}/\${year}:\${hour}:\${min}:\${sec} \${timezone}] \${method} \${path} \${protocol} \${responseCode} \${bytesSend}";
|
| - |
|
1480 |
|
| - |
|
1481 |
#尋找 http code 為 4xx 的內容行
|
| - |
|
1482 |
#函式說明:
|
| - |
|
1483 |
#尋找多個字串中是否含有符合多個格式之一的內容,且回傳解析好的變數數值.
|
| - |
|
1484 |
#回傳結果:
|
| - |
|
1485 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
1486 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
1487 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
1488 |
#$result["argu"],所使用的參數.
|
| - |
|
1489 |
#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
|
| - |
|
1490 |
#$result["content"],陣列,第一維為對應formats參數的索引,第二維的key為lineNo者為inputs參數的索引;第二維的key為content者為符合的資訊,若為n個${*},則當found為"true"時,就會回傳n個元素;第二維的key為parsedVar者為符合的資訊,其數值以變數名稱作為索引,元素的索引為0~N,代表有幾個符合的同名變數.
|
| - |
|
1491 |
#必填參數:
|
| - |
|
1492 |
#$conf["inputs"],字串陣列,要檢查的字串集合.
|
| - |
|
1493 |
$conf["search::getMatchFormatsStrings"]["inputs"]=$getFileContent["fileContent"];
|
| - |
|
1494 |
#$conf["format"],格式字串陣列,要尋找的可能格式字串集合.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
|
| - |
|
1495 |
$conf["search::getMatchFormatsStrings"]["formats"]=$formatsParamsOfsearchGetMatchFormatsStrings;
|
| - |
|
1496 |
#可省略參數:
|
| - |
|
1497 |
#無.
|
| - |
|
1498 |
#參考資料:
|
| - |
|
1499 |
#無.
|
| - |
|
1500 |
#備註:
|
| - |
|
1501 |
#無.
|
| - |
|
1502 |
$getMatchFormatsStrings=search::getMatchFormatsStrings($conf["search::getMatchFormatsStrings"]);
|
| - |
|
1503 |
unset($conf["search::getMatchFormatsStrings"]);
|
| - |
|
1504 |
|
| - |
|
1505 |
#如果執行異常
|
| - |
|
1506 |
if($getMatchFormatsStrings["status"]==="false"){
|
| - |
|
1507 |
|
| - |
|
1508 |
#設置執行失敗
|
| - |
|
1509 |
$result["status"]="false";
|
| - |
|
1510 |
|
| - |
|
1511 |
#設置錯誤訊息
|
| - |
|
1512 |
$result["error"]=$getMatchFormatsStrings;
|
| - |
|
1513 |
|
| - |
|
1514 |
#回傳結果
|
| - |
|
1515 |
return $result;
|
| - |
|
1516 |
|
| - |
|
1517 |
}#if end
|
| - |
|
1518 |
|
| - |
|
1519 |
#如果沒有符合的項目
|
| - |
|
1520 |
if($getMatchFormatsStrings["found"]==="false"){
|
| - |
|
1521 |
|
| - |
|
1522 |
#設置結果
|
| - |
|
1523 |
$result["content"]=array();
|
| - |
|
1524 |
|
| - |
|
1525 |
#設置執行正常
|
| - |
|
1526 |
$result["status"]="true";
|
| - |
|
1527 |
|
| - |
|
1528 |
#回傳結果
|
| - |
|
1529 |
return $result;
|
| - |
|
1530 |
|
| - |
|
1531 |
}#if end
|
| - |
|
1532 |
|
| - |
|
1533 |
#初始化要處理的ip資訊
|
| - |
|
1534 |
$ips=array();
|
| - |
|
1535 |
|
| - |
|
1536 |
#初始化用 ip 為索引來儲存資料行
|
| - |
|
1537 |
$ips_byIp=array();
|
| - |
|
1538 |
|
| - |
|
1539 |
#針對每個符合的規則
|
| - |
|
1540 |
foreach($getMatchFormatsStrings["content"] as $matchInfo){
|
| - |
|
1541 |
|
| - |
|
1542 |
#取得符合條件的行索引
|
| - |
|
1543 |
$index=$matchInfo["lineNo"];
|
| - |
|
1544 |
|
| - |
|
1545 |
#取得用戶要求的method
|
| - |
|
1546 |
$method=$matchInfo["parsedVar"][0]["method"][0];
|
| - |
|
1547 |
|
| - |
|
1548 |
#取得用戶要求的protocal
|
| - |
|
1549 |
$protocol=$matchInfo["parsedVar"][0]["protocol"][0];
|
| - |
|
1550 |
|
| - |
|
1551 |
#取得回應的code
|
| - |
|
1552 |
$responseCode=$matchInfo["parsedVar"][0]["responseCode"][0];
|
| - |
|
1553 |
|
| - |
|
1554 |
#如果 method 為 "CONNECT"
|
| - |
|
1555 |
if($method==="CONNECT"){
|
| - |
|
1556 |
|
| - |
|
1557 |
#這裡不做事情,但後面繼續執行
|
| - |
|
1558 |
|
| - |
|
1559 |
}#if end
|
| - |
|
1560 |
|
| - |
|
1561 |
#如果 protocol 為 "HTTP/1.0"
|
| - |
|
1562 |
else if($protocol==="HTTP/1.0"){
|
| - |
|
1563 |
|
| - |
|
1564 |
#這裡不做事情,但後面繼續執行
|
| - |
|
1565 |
|
| - |
|
1566 |
}#if end
|
| - |
|
1567 |
|
| - |
|
1568 |
#如果回應的 code 不為 4 開頭
|
| - |
|
1569 |
else if($responseCode[0]!=="4"){
|
| - |
|
1570 |
|
| - |
|
1571 |
#略過,看下一行
|
| - |
|
1572 |
continue;
|
| - |
|
1573 |
|
| - |
|
1574 |
}#if end
|
| - |
|
1575 |
|
| - |
|
1576 |
#取得用戶要求的路徑
|
| - |
|
1577 |
$path=$matchInfo["parsedVar"][0]["path"][0];
|
| - |
|
1578 |
|
| - |
|
1579 |
#剔除要求的資源名稱結尾為 ".css" ".js" "favicon.ico" ".jpg" ".png" 者. - start
|
| - |
|
1580 |
|
| - |
|
1581 |
#函式說明:
|
| - |
|
1582 |
#尋找字串中是否含有符合多個格式之一的內容,且回傳解析好的變數數值.
|
| - |
|
1583 |
#回傳結果:
|
| - |
|
1584 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
1585 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
1586 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
1587 |
#$result["argu"],所使用的參數.
|
| - |
|
1588 |
#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
|
| - |
|
1589 |
#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
|
| - |
|
1590 |
#必填參數:
|
| - |
|
1591 |
#$conf["input"],字串,要檢查的字串.
|
| - |
|
1592 |
$conf["search::findSpecifyStrFormats"]["input"]=$getFileContent["fileContent"][$index];
|
| - |
|
1593 |
#$conf["format"],格式字串陣列,要尋找的可能格式字串集合.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
|
| - |
|
1594 |
$conf["search::findSpecifyStrFormats"]["formats"]=array("\${str}.css","\${str}.js","\${str}.favicon.ico","\${str}.jpg","\${str}.jpeg","\${str}.png","\${str}.webp");
|
| - |
|
1595 |
#可省略參數:
|
| - |
|
1596 |
#無.
|
| - |
|
1597 |
#參考資料:
|
| - |
|
1598 |
#無.
|
| - |
|
1599 |
#備註:
|
| - |
|
1600 |
#無.
|
| - |
|
1601 |
$findSpecifyStrFormats=search::findSpecifyStrFormats($conf["search::findSpecifyStrFormats"]);
|
| - |
|
1602 |
unset($conf["search::findSpecifyStrFormats"]);
|
| - |
|
1603 |
|
| - |
|
1604 |
#如果執行異常
|
| - |
|
1605 |
if($findSpecifyStrFormats["status"]==="false"){
|
| - |
|
1606 |
|
| - |
|
1607 |
#設置執行失敗
|
| - |
|
1608 |
$result["status"]="false";
|
| - |
|
1609 |
|
| - |
|
1610 |
#設置錯誤訊息
|
| - |
|
1611 |
$result["error"]=$findSpecifyStrFormats;
|
| - |
|
1612 |
|
| - |
|
1613 |
#回傳結果
|
| - |
|
1614 |
return $result;
|
| - |
|
1615 |
|
| - |
|
1616 |
}#if end
|
| - |
|
1617 |
|
| - |
|
1618 |
#如果有符合的項目
|
| - |
|
1619 |
if($findSpecifyStrFormats["found"]==="true"){
|
| - |
|
1620 |
|
| - |
|
1621 |
#略過,看下一行
|
| - |
|
1622 |
continue;
|
| - |
|
1623 |
|
| - |
|
1624 |
}#if end
|
| - |
|
1625 |
|
| - |
|
1626 |
#剔除要求的資源名稱結尾為 ".css" ".js" "favicon.ico" ".jpg" ".jpeg" ".png" ".webp" 者. - end
|
| - |
|
1627 |
|
| - |
|
1628 |
#時間格式的參考
|
| - |
|
1629 |
# [\${day}/\${month}/\${year}:\${hour}:\${min}:\${sec} \${timezone}]
|
| - |
|
1630 |
|
| - |
|
1631 |
#取得 log 的時間點
|
| - |
|
1632 |
$time=$matchInfo["parsedVar"][0]["day"][0]."/".$matchInfo["parsedVar"][0]["month"][0]."/".$matchInfo["parsedVar"][0]["year"][0].":".$matchInfo["parsedVar"][0]["hour"][0].":".$matchInfo["parsedVar"][0]["min"][0].":".$matchInfo["parsedVar"][0]["sec"][0]." ".$matchInfo["parsedVar"][0]["timezone"][0];
|
| - |
|
1633 |
|
| - |
|
1634 |
#以 ip 為索引來儲存資料行
|
| - |
|
1635 |
$ips_byIp[$matchInfo["parsedVar"][0]["ip"][0]][]=array("log"=>$getFileContent["fileContent"][$index],"time"=>$time,"ip"=>$matchInfo["parsedVar"][0]["ip"][0]);
|
| - |
|
1636 |
|
| - |
|
1637 |
}#foreach end
|
| - |
|
1638 |
|
| - |
|
1639 |
#針對每個可能有問題的IP
|
| - |
|
1640 |
foreach($ips_byIp as $ip => $infos){
|
| - |
|
1641 |
|
| - |
|
1642 |
#計數 ip 於同時間前來的計數
|
| - |
|
1643 |
$ipSameTimeCount=0;
|
| - |
|
1644 |
|
| - |
|
1645 |
#用來存放來存取的同一時間
|
| - |
|
1646 |
$ipSameTime="";
|
| - |
|
1647 |
|
| - |
|
1648 |
#看來拜訪的時間點
|
| - |
|
1649 |
foreach($infos as $info){
|
| - |
|
1650 |
|
| - |
|
1651 |
#如果是初次
|
| - |
|
1652 |
if($ipSameTime===""){
|
| - |
|
1653 |
|
| - |
|
1654 |
#記錄時間點
|
| - |
|
1655 |
$ipSameTime=$info["time"];
|
| - |
|
1656 |
|
| - |
|
1657 |
#同時間點計數加1
|
| - |
|
1658 |
$ipSameTimeCount++;
|
| - |
|
1659 |
|
| - |
|
1660 |
}#if end
|
| - |
|
1661 |
|
| - |
|
1662 |
#反之如果時間點相同
|
| - |
|
1663 |
else if($ipSameTime===$info["time"]){
|
| - |
|
1664 |
|
| - |
|
1665 |
#同時間點計數加1
|
| - |
|
1666 |
$ipSameTimeCount++;
|
| - |
|
1667 |
|
| - |
|
1668 |
}#if end
|
| - |
|
1669 |
|
| - |
|
1670 |
#反之時間點不相同
|
| - |
|
1671 |
else{
|
| - |
|
1672 |
|
| - |
|
1673 |
#記錄時間點
|
| - |
|
1674 |
$ipSameTime=$info["time"];
|
| - |
|
1675 |
|
| - |
|
1676 |
#同時間點計數重設為1
|
| - |
|
1677 |
$ipSameTimeCount=1;
|
| - |
|
1678 |
|
| - |
|
1679 |
}#else end
|
| - |
|
1680 |
|
| - |
|
1681 |
#如果同時間的計數達到3
|
| - |
|
1682 |
if($ipSameTimeCount===3){
|
| - |
|
1683 |
|
| - |
|
1684 |
#初始化暫存的陣列
|
| - |
|
1685 |
$tmp=array();
|
| - |
|
1686 |
|
| - |
|
1687 |
#儲存資訊
|
| - |
|
1688 |
$tmp["info"]=$infos;
|
| - |
|
1689 |
|
| - |
|
1690 |
#儲存ip
|
| - |
|
1691 |
$tmp["ip"]=$info["ip"];
|
| - |
|
1692 |
|
| - |
|
1693 |
#取得有問題的IP
|
| - |
|
1694 |
$ips[]=$tmp;
|
| - |
|
1695 |
|
| - |
|
1696 |
#換檢查下一個IP
|
| - |
|
1697 |
continue 2;
|
| - |
|
1698 |
|
| - |
|
1699 |
}#if end
|
| - |
|
1700 |
|
| - |
|
1701 |
}#foreach end
|
| - |
|
1702 |
|
| - |
|
1703 |
}#foreach end
|
| - |
|
1704 |
|
| - |
|
1705 |
#設置結果
|
| - |
|
1706 |
$result["content"]=$ips;
|
| - |
|
1707 |
|
| - |
|
1708 |
#設置執行正常
|
| - |
|
1709 |
$result["status"]="true";
|
| - |
|
1710 |
|
| - |
|
1711 |
#回傳結果
|
| - |
|
1712 |
return $result;
|
| - |
|
1713 |
|
| - |
|
1714 |
}#funcion checkHttpAttackLog end
|
| - |
|
1715 |
|
| - |
|
1716 |
/*
|
| - |
|
1717 |
#函式說明:
|
| - |
|
1718 |
#檢查 postfixv log 中疑似攻擊的記錄.
|
| - |
|
1719 |
#回傳結果:
|
| - |
|
1720 |
#$result["status"],字串,執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
1721 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
1722 |
#$result["function"],字串,當前執行的函式名稱.
|
| - |
|
1723 |
#$result["content"],陣列,攻擊記錄資訊,每個元素為陣列key為"ip"者為攻擊者的ip;key為info者為其資訊陣列,其key為"log"者代表log的行內容;key為"time"者代表時間點;key為ip者代表ip.
|
| - |
|
1724 |
#必填參數:
|
| - |
|
1725 |
#無.
|
| - |
|
1726 |
#可省略參數:
|
| - |
|
1727 |
#無
|
| - |
|
1728 |
#參考資料:
|
| - |
|
1729 |
#無.
|
| - |
|
1730 |
#備註:
|
| - |
|
1731 |
#無.
|
| - |
|
1732 |
*/
|
| - |
|
1733 |
public static function checkPostfixAttackLog(){
|
| - |
|
1734 |
|
| - |
|
1735 |
#初始化要回傳的結果
|
| - |
|
1736 |
$result=array();
|
| - |
|
1737 |
|
| - |
|
1738 |
#取得當前執行的函數名稱
|
| - |
|
1739 |
$result["function"]=__FUNCTION__;
|
| - |
|
1740 |
|
| - |
|
1741 |
#透過 journalctl -a -e -f --unit=postfix.service | grep "authentication failed" 來取得認證失敗的 ip
|
| - |
|
1742 |
#函式說明:
|
| - |
|
1743 |
#呼叫shell執行系統命令,並取得回傳的內容.
|
| - |
|
1744 |
#回傳的結果:
|
| - |
|
1745 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
1746 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
1747 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
1748 |
#$result["argu"],使用的參數.
|
| - |
|
1749 |
#$result["cmd"],執行的指令內容.
|
| - |
|
1750 |
#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
1751 |
#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
|
| - |
|
1752 |
#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
1753 |
#$result["running"],是否還在執行.
|
| - |
|
1754 |
#$result["pid"],pid.
|
| - |
|
1755 |
#$result["statusCode"],執行結束後的代碼.
|
| - |
|
1756 |
#必填參數:
|
| - |
|
1757 |
#$conf["command"],字串,要執行的指令與.
|
| - |
|
1758 |
$conf["external::callShell"]["command"]="journalctl";
|
| - |
|
1759 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
| - |
|
1760 |
$conf["external::callShell"]["fileArgu"]=__FILE__;
|
| - |
|
1761 |
#可省略參數:
|
| - |
|
1762 |
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
|
| - |
|
1763 |
$conf["external::callShell"]["argu"]=array("-a","-e","--unit=postfix.service","|","grep","authentication failed","|","cat");
|
| - |
|
1764 |
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
|
| - |
|
1765 |
#$conf["arguIsAddr"]=array();
|
| - |
|
1766 |
#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
|
| - |
|
1767 |
#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
|
| - |
|
1768 |
#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
|
| - |
|
1769 |
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
|
| - |
|
1770 |
#$conf["enablePrintDescription"]="true";
|
| - |
|
1771 |
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
|
| - |
|
1772 |
#$conf["printDescription"]="";
|
| - |
|
1773 |
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
|
| - |
|
1774 |
$conf["external::callShell"]["escapeshellarg"]="true";
|
| - |
|
1775 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
| - |
|
1776 |
#$conf["username"]="";
|
| - |
|
1777 |
#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
| - |
|
1778 |
#$conf["password"]="";
|
| - |
|
1779 |
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
|
| - |
|
1780 |
#$conf["useScript"]="";
|
| - |
|
1781 |
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
|
| - |
|
1782 |
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
|
| - |
|
1783 |
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
|
| - |
|
1784 |
#$conf["inBackGround"]="";
|
| - |
|
1785 |
#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
|
| - |
|
1786 |
#$conf["getErr"]="false";
|
| - |
|
1787 |
#備註:
|
| - |
|
1788 |
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
|
| - |
|
1789 |
#參考資料:
|
| - |
|
1790 |
#exec=>http://php.net/manual/en/function.exec.php
|
| - |
|
1791 |
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
|
| - |
|
1792 |
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
|
| - |
|
1793 |
$callShell=external::callShell($conf["external::callShell"]);
|
| - |
|
1794 |
unset($conf["external::callShell"]);
|
| - |
|
1795 |
|
| - |
|
1796 |
if($callShell["status"]==="false"){
|
| - |
|
1797 |
|
| - |
|
1798 |
#如果有 statusCode
|
| - |
|
1799 |
if(isset($callShell["statusCode"])){
|
| - |
|
1800 |
|
| - |
|
1801 |
#如果shell回傳不為0也不為1
|
| - |
|
1802 |
if($callShell["statusCode"]!==0 && $callShell["statusCode"]!==1){
|
| - |
|
1803 |
|
| - |
|
1804 |
#設置執行失敗
|
| - |
|
1805 |
$result["status"]="false";
|
| - |
|
1806 |
|
| - |
|
1807 |
#設置錯誤訊息
|
| - |
|
1808 |
$result["error"]=$callShell;
|
| - |
|
1809 |
|
| - |
|
1810 |
#回傳結果
|
| - |
|
1811 |
return $result;
|
| - |
|
1812 |
|
| - |
|
1813 |
}#if end
|
| - |
|
1814 |
|
| - |
|
1815 |
}#if end
|
| - |
|
1816 |
|
| - |
|
1817 |
#設置執行失敗
|
| - |
|
1818 |
$result["status"]="false";
|
| - |
|
1819 |
|
| - |
|
1820 |
#設置錯誤訊息
|
| - |
|
1821 |
$result["error"]=$callShell;
|
| - |
|
1822 |
|
| - |
|
1823 |
#回傳結果
|
| - |
|
1824 |
return $result;
|
| - |
|
1825 |
|
| - |
|
1826 |
}#if end
|
| - |
|
1827 |
|
| - |
|
1828 |
#儲存有問題的smtp IP
|
| - |
|
1829 |
$ips_smtp=array();
|
| - |
|
1830 |
|
| - |
|
1831 |
#狀態碼不為1才執行
|
| - |
|
1832 |
if($callShell["statusCode"]!==1){
|
| - |
|
1833 |
|
| - |
|
1834 |
#初始化記錄每行log的時間點
|
| - |
|
1835 |
$occurTime=array();
|
| - |
|
1836 |
|
| - |
|
1837 |
#初始化儲存log行資訊的變數
|
| - |
|
1838 |
$oriLog=array();
|
| - |
|
1839 |
|
| - |
|
1840 |
#根據每筆記錄
|
| - |
|
1841 |
foreach($callShell["output"] as $index => $line){
|
| - |
|
1842 |
|
| - |
|
1843 |
#截取出的格式
|
| - |
|
1844 |
#Sep 28 07:54:16 qbpwcf.org postfix/smtpd[2766456]: warning: unknown[158.94.208.72]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=1q2w
|
| - |
|
1845 |
#Sep 28 07:57:15 qbpwcf.org postfix/smtpd[2768441]: warning: unknown[213.209.157.249]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=sybase
|
| - |
|
1846 |
#Sep 28 08:01:09 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[213.209.157.165]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=spam
|
| - |
|
1847 |
#Sep 28 08:01:51 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[103.109.20.174]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=print@qbpwcf.org
|
| - |
|
1848 |
#Sep 28 08:03:14 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[62.60.130.148]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=admin2
|
| - |
|
1849 |
#Sep 28 08:16:06 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[103.109.20.174]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=user@qbpwcf.org
|
| - |
|
1850 |
#Sep 28 08:16:44 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=hualing@qbpwcf.org
|
| - |
|
1851 |
#Sep 28 08:16:53 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=hualing@qbpwcf.org
|
| - |
|
1852 |
#Sep 28 08:17:06 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=hualing@qbpwcf.org
|
| - |
|
1853 |
#Sep 28 08:17:16 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]: SASL LOGIN authentication failed: Connection lost to authentication server, sasl_username=hualing@qbpwcf.org
|
| - |
|
1854 |
#Sep 28 08:20:28 qbpwcf.org postfix/smtpd[2784204]: warning: unknown[158.94.208.72]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=1q2w1q2w
|
| - |
|
1855 |
#Sep 28 08:23:09 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[213.209.157.249]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=informix
|
| - |
|
1856 |
#Sep 28 08:23:39 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[62.60.130.148]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=admin3
|
| - |
|
1857 |
#May 22 12:58:54 qbpwcf.org postfix/smtpd[2059124]: warning: unknown[80.94.95.242]: SASL LOGIN authentication failed: Invalid authentication mechanism: 'LOGIN', sasl_username=(unavailable)
|
| - |
|
1858 |
#May 22 12:58:59 qbpwcf.org postfix/smtpd[2059124]: warning: unknown[80.94.95.242]: SASL PLAIN authentication failed: (reason unavailable), sasl_username=nonexistent_user_26@qbpwcf.org
|
| - |
|
1859 |
#May 22 12:59:07 qbpwcf.org postfix/smtpd[2059124]: warning: unknown[80.94.95.242]: SASL PLAIN authentication failed: (reason unavailable), sasl_username=finance@qbpwcf.org#"${doNotNeed} postfix/smtpd[${pid}]${doNotNeed}[${ip}]"
|
| - |
|
1860 |
|
| - |
|
1861 |
#用 " " 分割 以取得 月日時分秒
|
| - |
|
1862 |
#函式說明:
|
| - |
|
1863 |
#將固定格式的字串分開,並回傳分開的結果.
|
| - |
|
1864 |
#回傳結果:
|
| - |
|
1865 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
1866 |
#$result["error"],錯誤訊息陣列
|
| - |
|
1867 |
#$result["function"],當前執行的函數名稱.
|
| - |
|
1868 |
#$result["argu"],使用的參數.
|
| - |
|
1869 |
#$result["oriStr"],要分割的原始字串內容
|
| - |
|
1870 |
#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
|
| - |
|
1871 |
#$result["dataCounts"],爲總共分成幾段
|
| - |
|
1872 |
#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
|
| - |
|
1873 |
#必填參數:
|
| - |
|
1874 |
#$conf["stringIn"],字串,要處理的字串.
|
| - |
|
1875 |
$conf["stringProcess::spiltString"]["stringIn"]=$line;
|
| - |
|
1876 |
#$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
|
| - |
|
1877 |
$conf["stringProcess::spiltString"]["spiltSymbol"]=" ";
|
| - |
|
1878 |
#可省略參數:
|
| - |
|
1879 |
#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
|
| - |
|
1880 |
#$conf["allowEmptyStr"]="false";
|
| - |
|
1881 |
#參考資料:
|
| - |
|
1882 |
#無.
|
| - |
|
1883 |
#備註:
|
| - |
|
1884 |
#無.
|
| - |
|
1885 |
$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
|
| - |
|
1886 |
unset($conf["stringProcess::spiltString"]);
|
| - |
|
1887 |
|
| - |
|
1888 |
#如果分割失敗
|
| - |
|
1889 |
if($spiltString["status"]==="false"){
|
| - |
|
1890 |
|
| - |
|
1891 |
#設置執行失敗
|
| - |
|
1892 |
$result["status"]="false";
|
| - |
|
1893 |
|
| - |
|
1894 |
#設置錯誤訊息
|
| - |
|
1895 |
$result["error"]=$spiltString;
|
| - |
|
1896 |
|
| - |
|
1897 |
#回傳結果
|
| - |
|
1898 |
return $result;
|
| - |
|
1899 |
|
| - |
|
1900 |
}#if end
|
| - |
|
1901 |
|
| - |
|
1902 |
#如果分割失敗
|
| - |
|
1903 |
if($spiltString["dataCounts"]<3){
|
| - |
|
1904 |
|
| - |
|
1905 |
#設置執行失敗
|
| - |
|
1906 |
$result["status"]="false";
|
| - |
|
1907 |
|
| - |
|
1908 |
#設置錯誤訊息
|
| - |
|
1909 |
$result["error"]=$spiltString;
|
| - |
|
1910 |
|
| - |
|
1911 |
#回傳結果
|
| - |
|
1912 |
return $result;
|
| - |
|
1913 |
|
| - |
|
1914 |
}#if end
|
| - |
|
1915 |
|
| - |
|
1916 |
#儲存時間
|
| - |
|
1917 |
$occurTime[$index]=strtotime($spiltString["dataArray"][0]." ".$spiltString["dataArray"][1]." ".$spiltString["dataArray"][2]);
|
| - |
|
1918 |
|
| - |
|
1919 |
#取得 ip
|
| - |
|
1920 |
#函式說明:
|
| - |
|
1921 |
#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
|
| - |
|
1922 |
#回傳結果:
|
| - |
|
1923 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
1924 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
1925 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
1926 |
#$result["argu"],所使用的參數.
|
| - |
|
1927 |
#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
|
| - |
|
1928 |
#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
|
| - |
|
1929 |
#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
|
| - |
|
1930 |
#必填參數:
|
| - |
|
1931 |
#$conf["input"],字串,要檢查的字串.
|
| - |
|
1932 |
$conf["search::findSpecifyStrFormat"]["input"]=$line;
|
| - |
|
1933 |
#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
|
| - |
|
1934 |
$conf["search::findSpecifyStrFormat"]["format"]="\${doNotNeed} postfix/smtpd[\${pid}]\${doNotNeed}[\${ip}]:[\${reason}]";
|
| - |
|
1935 |
#可省略參數:
|
| - |
|
1936 |
#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
|
| - |
|
1937 |
#$conf["search::findSpecifyStrFormat"]["varEqual"]=array(null,"found");
|
| - |
|
1938 |
#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
|
| - |
|
1939 |
#$conf["varCon"]=array("no_tail"=>" not");
|
| - |
|
1940 |
#參考資料:
|
| - |
|
1941 |
#無.
|
| - |
|
1942 |
#備註:
|
| - |
|
1943 |
#無.
|
| - |
|
1944 |
$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
|
| - |
|
1945 |
unset($conf["search::findSpecifyStrFormat"]);
|
| - |
|
1946 |
|
| - |
|
1947 |
#如果分割失敗
|
| - |
|
1948 |
if($findSpecifyStrFormat["status"]==="false"){
|
| - |
|
1949 |
|
| - |
|
1950 |
#設置執行失敗
|
| - |
|
1951 |
$result["status"]="false";
|
| - |
|
1952 |
|
| - |
|
1953 |
#設置錯誤訊息
|
| - |
|
1954 |
$result["error"]=$findSpecifyStrFormat;
|
| - |
|
1955 |
|
| - |
|
1956 |
#回傳結果
|
| - |
|
1957 |
return $result;
|
| - |
|
1958 |
|
| - |
|
1959 |
}#if end
|
| - |
|
1960 |
|
| - |
|
1961 |
#如果沒有符合格式
|
| - |
|
1962 |
if($findSpecifyStrFormat["found"]==="false"){
|
| - |
|
1963 |
|
| - |
|
1964 |
#剔除時間點 記錄
|
| - |
|
1965 |
array_pop($occurTime);
|
| - |
|
1966 |
|
| - |
|
1967 |
#跳過該行
|
| - |
|
1968 |
continue;
|
| - |
|
1969 |
|
| - |
|
1970 |
}#if end
|
| - |
|
1971 |
|
| - |
|
1972 |
#取得解析好的ip
|
| - |
|
1973 |
$ip=$findSpecifyStrFormat["parsedVar"]["ip"];
|
| - |
|
1974 |
|
| - |
|
1975 |
#儲存原始的log行內容
|
| - |
|
1976 |
$oriLog[$index]=$spiltMutiString["spiltString"][$index ]["oriStr"];
|
| - |
|
1977 |
|
| - |
|
1978 |
#初始化暫存的陣列
|
| - |
|
1979 |
$tmp=array();
|
| - |
|
1980 |
|
| - |
|
1981 |
#設置log、time
|
| - |
|
1982 |
$tmp["info"][]=array("log"=>$oriLog[$index],"time"=>$occurTime[$index]);
|
| - |
|
1983 |
|
| - |
|
1984 |
#設置問題ip
|
| - |
|
1985 |
$tmp["ip"]=$ip;
|
| - |
|
1986 |
|
| - |
|
1987 |
#取得所需的有問題的IP
|
| - |
|
1988 |
$ips_smtp[]=$tmp;
|
| - |
|
1989 |
|
| - |
|
1990 |
}#foreach end
|
| - |
|
1991 |
|
| - |
|
1992 |
}#if end
|
| - |
|
1993 |
|
| - |
|
1994 |
#設置結果
|
| - |
|
1995 |
$result["content"]=$ips_smtp;
|
| - |
|
1996 |
|
| - |
|
1997 |
#設置執行正常
|
| - |
|
1998 |
$result["status"]="true";
|
| - |
|
1999 |
|
| - |
|
2000 |
#回傳結果
|
| - |
|
2001 |
return $result;
|
| - |
|
2002 |
|
| - |
|
2003 |
}#function checkPostfixAttackLog end
|
| - |
|
2004 |
|
| - |
|
2005 |
/*
|
| - |
|
2006 |
#函式說明:
|
| - |
|
2007 |
#檢查 named log 中疑似攻擊的記錄.
|
| - |
|
2008 |
#回傳結果:
|
| - |
|
2009 |
#$result["status"],字串,執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
2010 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
2011 |
#$result["function"],字串,當前執行的函式名稱.
|
| - |
|
2012 |
#$result["content"],陣列,攻擊記錄資訊,每個元素為陣列key為"ip"者為攻擊者的ip;key為info者為其資訊陣列,其key為"log"者代表log的行內容;key為"time"者代表時間點;key為ip者代表ip.
|
| - |
|
2013 |
#必填參數:
|
| - |
|
2014 |
#無.
|
| - |
|
2015 |
#可省略參數:
|
| - |
|
2016 |
#無
|
| - |
|
2017 |
#參考資料:
|
| - |
|
2018 |
#無.
|
| - |
|
2019 |
#備註:
|
| - |
|
2020 |
#無.
|
| - |
|
2021 |
*/
|
| - |
|
2022 |
public static function checkNamedAttackLog(){
|
| - |
|
2023 |
|
| - |
|
2024 |
#初始化要回傳的結果
|
| - |
|
2025 |
$result=array();
|
| - |
|
2026 |
|
| - |
|
2027 |
#取得當前執行的函數名稱
|
| - |
|
2028 |
$result["function"]=__FUNCTION__;
|
| - |
|
2029 |
|
| - |
|
2030 |
#透過 journalctl -a -e -f --unit=named.service | grep ' query ' 來取得 IP
|
| - |
|
2031 |
#函式說明:
|
| - |
|
2032 |
#呼叫shell執行系統命令,並取得回傳的內容.
|
| - |
|
2033 |
#回傳的結果:
|
| - |
|
2034 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
2035 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
2036 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
2037 |
#$result["argu"],使用的參數.
|
| - |
|
2038 |
#$result["cmd"],執行的指令內容.
|
| - |
|
2039 |
#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
2040 |
#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
|
| - |
|
2041 |
#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
2042 |
#$result["running"],是否還在執行.
|
| - |
|
2043 |
#$result["pid"],pid.
|
| - |
|
2044 |
#$result["statusCode"],執行結束後的代碼.
|
| - |
|
2045 |
#必填參數:
|
| - |
|
2046 |
#$conf["command"],字串,要執行的指令與.
|
| - |
|
2047 |
$conf["external::callShell"]["command"]="journalctl";
|
| - |
|
2048 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
| - |
|
2049 |
$conf["external::callShell"]["fileArgu"]=__FILE__;
|
| - |
|
2050 |
#可省略參數:
|
| - |
|
2051 |
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
|
| - |
|
2052 |
$conf["external::callShell"]["argu"]=array("-a","-e","--unit=named.service","|","grep"," query ","|","cat");
|
| - |
|
2053 |
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
|
| - |
|
2054 |
#$conf["arguIsAddr"]=array();
|
| - |
|
2055 |
#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
|
| - |
|
2056 |
#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
|
| - |
|
2057 |
#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
|
| - |
|
2058 |
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
|
| - |
|
2059 |
#$conf["enablePrintDescription"]="true";
|
| - |
|
2060 |
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
|
| - |
|
2061 |
#$conf["printDescription"]="";
|
| - |
|
2062 |
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
|
| - |
|
2063 |
$conf["external::callShell"]["escapeshellarg"]="true";
|
| - |
|
2064 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
| - |
|
2065 |
#$conf["username"]="";
|
| - |
|
2066 |
#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
| - |
|
2067 |
#$conf["password"]="";
|
| - |
|
2068 |
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
|
| - |
|
2069 |
#$conf["useScript"]="";
|
| - |
|
2070 |
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
|
| - |
|
2071 |
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
|
| - |
|
2072 |
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
|
| - |
|
2073 |
#$conf["inBackGround"]="";
|
| - |
|
2074 |
#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
|
| - |
|
2075 |
#$conf["getErr"]="false";
|
| - |
|
2076 |
#備註:
|
| - |
|
2077 |
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
|
| - |
|
2078 |
#參考資料:
|
| - |
|
2079 |
#exec=>http://php.net/manual/en/function.exec.php
|
| - |
|
2080 |
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
|
| - |
|
2081 |
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
|
| - |
|
2082 |
$callShell=external::callShell($conf["external::callShell"]);
|
| - |
|
2083 |
unset($conf["external::callShell"]);
|
| - |
|
2084 |
|
| - |
|
2085 |
#如果執行失敗
|
| - |
|
2086 |
if($callShell["status"]==="false"){
|
| - |
|
2087 |
|
| - |
|
2088 |
#如果有 statusCode
|
| - |
|
2089 |
if(isset($callShell["statusCode"])){
|
| - |
|
2090 |
|
| - |
|
2091 |
#如果shell回傳不為0也不為1
|
| - |
|
2092 |
if($callShell["statusCode"]!==0 && $callShell["statusCode"]!==1){
|
| - |
|
2093 |
|
| - |
|
2094 |
#設置執行失敗
|
| - |
|
2095 |
$result["status"]="false";
|
| - |
|
2096 |
|
| - |
|
2097 |
#設置錯誤訊息
|
| - |
|
2098 |
$result["error"]=$callShell;
|
| - |
|
2099 |
|
| - |
|
2100 |
#回傳結果
|
| - |
|
2101 |
return $result;
|
| - |
|
2102 |
|
| - |
|
2103 |
}#if end
|
| - |
|
2104 |
|
| - |
|
2105 |
}#if end
|
| - |
|
2106 |
|
| - |
|
2107 |
#設置執行失敗
|
| - |
|
2108 |
$result["status"]="false";
|
| - |
|
2109 |
|
| - |
|
2110 |
#設置錯誤訊息
|
| - |
|
2111 |
$result["error"]=$callShell;
|
| - |
|
2112 |
|
| - |
|
2113 |
#回傳結果
|
| - |
|
2114 |
return $result;
|
| - |
|
2115 |
|
| - |
|
2116 |
}#if end
|
| - |
|
2117 |
|
| - |
|
2118 |
#記錄攻擊者的IP
|
| - |
|
2119 |
$attacker_ips_namd=array();
|
| - |
|
2120 |
|
| - |
|
2121 |
#狀態碼不為1才執行
|
| - |
|
2122 |
if($callShell["statusCode"]!==1){
|
| - |
|
2123 |
|
| - |
|
2124 |
#截取出的格式
|
| - |
|
2125 |
#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f7714041d10 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2126 |
#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f77180297c0 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2127 |
#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f7714041d10 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2128 |
#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f77180297c0 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2129 |
#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f7714041d10 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2130 |
#Nov 24 20:55:17 localhost.localdomain named[99512]: client @0x7f7714041d10 34.80.86.198#31220 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2131 |
#Nov 24 20:55:17 localhost.localdomain named[99512]: client @0x7f7714041d10 34.80.86.198#31220 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2132 |
#Nov 24 20:55:17 localhost.localdomain named[99512]: client @0x7f7714041d10 34.80.86.198#31220 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2133 |
#Nov 24 20:55:17 localhost.localdomain named[99512]: client @0x7f77180297c0 34.80.86.198#31220 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2134 |
#Nov 24 20:55:17 localhost.localdomain named[99512]: client @0x7f770c077bf0 34.80.86.198#31220 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2135 |
#Nov 24 20:55:17 localhost.localdomain named[99512]: client @0x7f770c077bf0 191.7.219.100#8794 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2136 |
#Nov 24 20:55:17 localhost.localdomain named[99512]: client @0x7f77180297c0 191.7.219.100#8794 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2137 |
#Nov 24 20:55:17 localhost.localdomain named[99512]: client @0x7f770c077bf0 191.7.219.100#8794 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2138 |
#Nov 24 20:55:17 localhost.localdomain named[99512]: client @0x7f7714041d10 191.7.219.100#8794 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2139 |
#Nov 24 20:55:18 localhost.localdomain named[99512]: client @0x7f770c077bf0 5.29.224.190#10027 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2140 |
#Nov 24 20:55:18 localhost.localdomain named[99512]: client @0x7f770c077bf0 5.29.224.190#10027 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2141 |
#Nov 24 20:55:18 localhost.localdomain named[99512]: client @0x7f7714041d10 5.29.224.190#10027 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2142 |
#Nov 24 20:55:18 localhost.localdomain named[99512]: client @0x7f77180297c0 5.29.224.190#10027 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2143 |
#Nov 24 20:55:18 localhost.localdomain named[99512]: client @0x7f7714041d10 5.29.224.190#10027 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2144 |
#Nov 24 20:55:18 localhost.localdomain named[99512]: client @0x7f77180297c0 5.29.224.190#10027 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2145 |
#Nov 24 20:55:18 localhost.localdomain named[99512]: client @0x7f7714041d10 5.29.224.190#10027 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2146 |
#Nov 24 20:55:22 localhost.localdomain named[99512]: client @0x7f7714041d10 123.253.64.16#54404 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2147 |
#Nov 24 20:55:22 localhost.localdomain named[99512]: client @0x7f7714041d10 123.253.64.16#54404 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2148 |
#Nov 24 20:55:22 localhost.localdomain named[99512]: client @0x7f7714041d10 123.253.64.16#54404 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
|
| - |
|
2149 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc801bc80 61.220.11.198#40052 (dns.qbpwcf.org): query 'dns.qbpwcf.org/AAAA/IN' denied
|
| - |
|
2150 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc8003700 61.220.11.198#48628 (aesopower-cms-sock-latest.qbpwcf.org): query 'aesopower-cms-sock-latest.qbpwcf.org/A/IN' denied
|
| - |
|
2151 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc8003700 61.220.11.198#52460 (dns.qbpwcf.org): query 'dns.qbpwcf.org/AAAA/IN' denied
|
| - |
|
2152 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc801bc80 61.220.11.198#60457 (aesopower-cms-sock-latest.qbpwcf.org): query 'aesopower-cms-sock-latest.qbpwcf.org/A/IN' denied
|
| - |
|
2153 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc801bc80 61.220.11.198#10213 (dns.qbpwcf.org): query 'dns.qbpwcf.org/AAAA/IN' denied
|
| - |
|
2154 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc801bc80 61.220.11.198#44377 (aesopower-cms-sock-latest.qbpwcf.org): query 'aesopower-cms-sock-latest.qbpwcf.org/A/IN' denied
|
| - |
|
2155 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc8003700 61.220.11.198#4481 (dns.qbpwcf.org): query 'dns.qbpwcf.org/AAAA/IN' denied
|
| - |
|
2156 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc8003700 61.220.11.198#53061 (aesopower-cms-sock-latest.qbpwcf.org): query 'aesopower-cms-sock-latest.qbpwcf.org/A/IN' denied
|
| - |
|
2157 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc8003700 61.220.11.198#31654 (dns.qbpwcf.org): query 'dns.qbpwcf.org/AAAA/IN' denied
|
| - |
|
2158 |
#Dec 14 18:51:45 localhost.localdomain named[1159]: client @0x7f3dc802a410 61.220.11.198#57701 (aesopower-cms-sock-latest.qbpwcf.org): query 'aesopower-cms-sock-latest.qbpwcf.org/A/IN' denied
|
| - |
|
2159 |
#Sep 29 03:37:20 dns.qbpwcf.org named[94]: client @0x7f60e00734e8 61.166.210.84#49954 (twitter.com): query failed (REFUSED) for twitter.com/IN/AAAA at ../../../lib/ns/query.c:5691
|
| - |
|
2160 |
#Sep 29 03:37:20 dns.qbpwcf.org named[94]: client @0x7f60e006f428 61.166.210.84#49954 (twitter.com): query failed (REFUSED) for twitter.com/IN/A at ../../../lib/ns/query.c:5691
|
| - |
|
2161 |
#Sep 29 03:37:21 dns.qbpwcf.org named[94]: client @0x7f60e80889a8 61.166.210.84#50057 (astrill4u.com): query failed (REFUSED) for astrill4u.com/IN/AAAA at ../../../lib/ns/query.c:5691
|
| - |
|
2162 |
#Sep 29 03:37:21 dns.qbpwcf.org named[94]: client @0x7f60e805ed08 61.166.210.84#50057 (astrill4u.com): query failed (REFUSED) for astrill4u.com/IN/A at ../../../lib/ns/query.c:5691
|
| - |
|
2163 |
#Sep 29 03:46:33 dns.qbpwcf.org named[94]: client @0x7f60d402b618 165.22.223.147#16200 (tool.lu): query failed (REFUSED) for tool.lu/IN/A at ../../../lib/ns/query.c:5691
|
| - |
|
2164 |
#Sep 29 03:49:16 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
|
| - |
|
2165 |
#Sep 29 04:19:10 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
|
| - |
|
2166 |
#Sep 29 04:20:28 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
|
| - |
|
2167 |
#Sep 29 04:24:20 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
|
| - |
|
2168 |
#Sep 29 04:24:59 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
|
| - |
|
2169 |
#Sep 29 04:40:48 dns.qbpwcf.org named[94]: client @0x7f60f9377888 174.96.56.126#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
|
| - |
|
2170 |
#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} client ${doNotNeed} ${ip}#${remoteRevPort} (${$queryTarget}): ${doNotNeed}
|
| - |
|
2171 |
|
| - |
|
2172 |
#函式說明:
|
| - |
|
2173 |
#檢查多個字串中的每個字串是否有多個關鍵字
|
| - |
|
2174 |
#回傳結果:
|
| - |
|
2175 |
#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
|
| - |
|
2176 |
#$result["function"],當前執行的函數名稱.
|
| - |
|
2177 |
#$result["error"],錯誤訊息.
|
| - |
|
2178 |
#$result["argu"],使用的參數.
|
| - |
|
2179 |
#$result["foundedTrueKey"],結果為"true"的被搜尋元素key陣列,與其數值內容.
|
| - |
|
2180 |
#$result["foundedKeyWords"],找到的關鍵字陣列.
|
| - |
|
2181 |
#$result["foundedFalseKey"],結果為"false"的被搜尋元素key陣列,與其數值內容.
|
| - |
|
2182 |
#$result["foundedTrueKeyWords"],二維陣列,各個字串有找到的關鍵字陣列.
|
| - |
|
2183 |
#$result["foundedAll"],是否每個關鍵字都有找到,"true"代表每個都有找到,"false"代表沒有每個都找到.
|
| - |
|
2184 |
#$result["keyWordsIncludeStr"],陣列,儲存有找到關鍵字的來源的索引(sourceIndex)與其內容(sourceVal)跟找到的關鍵字項目陣列(KeyWords).
|
| - |
|
2185 |
#必填參數:
|
| - |
|
2186 |
#$conf["keyWords"],字串陣列,想要搜尋的關鍵字.
|
| - |
|
2187 |
$conf["search::findManyKeyWordsFromManyString"]["keyWords"]=array("(REFUSED)"," denied");
|
| - |
|
2188 |
#$conf["stringArray"],字串陣列,要被搜尋的字串內容陣列.
|
| - |
|
2189 |
$conf["search::findManyKeyWordsFromManyString"]["stringArray"]=$callShell["output"];
|
| - |
|
2190 |
#可省略參數:
|
| - |
|
2191 |
#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為"false"不需要完全符合.
|
| - |
|
2192 |
#$conf["completeEqual"]="true";
|
| - |
|
2193 |
#參考資料:
|
| - |
|
2194 |
#無.
|
| - |
|
2195 |
#備註:
|
| - |
|
2196 |
#無.
|
| - |
|
2197 |
$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
|
| - |
|
2198 |
unset($conf["search::findManyKeyWordsFromManyString"]);
|
| - |
|
2199 |
|
| - |
|
2200 |
#如果執行失敗
|
| - |
|
2201 |
if($findManyKeyWordsFromManyString["status"]==="false"){
|
| - |
|
2202 |
|
| - |
|
2203 |
#設置執行失敗
|
| - |
|
2204 |
$result["status"]="false";
|
| - |
|
2205 |
|
| - |
|
2206 |
#設置錯誤訊息
|
| - |
|
2207 |
$result["error"]=$findManyKeyWordsFromManyString;
|
| - |
|
2208 |
|
| - |
|
2209 |
#回傳結果
|
| - |
|
2210 |
return $result;
|
| - |
|
2211 |
|
| - |
|
2212 |
}#if end
|
| - |
|
2213 |
|
| - |
|
2214 |
#初始化儲存原始log行內容
|
| - |
|
2215 |
#$oriLog=array();
|
| - |
|
2216 |
|
| - |
|
2217 |
#儲存疑似有問題的IP
|
| - |
|
2218 |
$ips_named=array();
|
| - |
|
2219 |
|
| - |
|
2220 |
#初始化儲存確定有問題的ip
|
| - |
|
2221 |
$attacker_ips_namd=array();
|
| - |
|
2222 |
|
| - |
|
2223 |
#針對每個符合的行
|
| - |
|
2224 |
foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $oriLog){
|
| - |
|
2225 |
|
| - |
|
2226 |
#初始化儲存資訊的暫存陣列
|
| - |
|
2227 |
$info=array();
|
| - |
|
2228 |
|
| - |
|
2229 |
#解析時間與來源ip
|
| - |
|
2230 |
#函式說明:
|
| - |
|
2231 |
#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
|
| - |
|
2232 |
#回傳結果:
|
| - |
|
2233 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
2234 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
2235 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
2236 |
#$result["argu"],所使用的參數.
|
| - |
|
2237 |
#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
|
| - |
|
2238 |
#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
|
| - |
|
2239 |
#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
|
| - |
|
2240 |
#必填參數:
|
| - |
|
2241 |
#$conf["input"],字串,要檢查的字串.
|
| - |
|
2242 |
$conf["search::findSpecifyStrFormat"]["input"]=$oriLog;
|
| - |
|
2243 |
#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
|
| - |
|
2244 |
$conf["search::findSpecifyStrFormat"]["format"]="\${month} \${day} \${hour}:\${min}:\${sec} \${doNotNeed} client \${doNotNeed} \${ip}#\${remoteRevPort} (\${queryTarget}): \${doNotNeed}";
|
| - |
|
2245 |
#可省略參數:
|
| - |
|
2246 |
#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
|
| - |
|
2247 |
#$conf["search::findSpecifyStrFormat"]["varEqual"]=array(null,"found");
|
| - |
|
2248 |
#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
|
| - |
|
2249 |
#$conf["varCon"]=array("no_tail"=>" not");
|
| - |
|
2250 |
#參考資料:
|
| - |
|
2251 |
#無.
|
| - |
|
2252 |
#備註:
|
| - |
|
2253 |
#無.
|
| - |
|
2254 |
$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
|
| - |
|
2255 |
unset($conf["search::findSpecifyStrFormat"]);
|
| - |
|
2256 |
|
| - |
|
2257 |
#如果分割失敗
|
| - |
|
2258 |
if($findSpecifyStrFormat["status"]==="false"){
|
| - |
|
2259 |
|
| - |
|
2260 |
#設置執行失敗
|
| - |
|
2261 |
$result["status"]="false";
|
| - |
|
2262 |
|
| - |
|
2263 |
#設置錯誤訊息
|
| - |
|
2264 |
$result["error"]=$findSpecifyStrFormat;
|
| - |
|
2265 |
|
| - |
|
2266 |
#回傳結果
|
| - |
|
2267 |
return $result;
|
| - |
|
2268 |
|
| - |
|
2269 |
}#if end
|
| - |
|
2270 |
|
| - |
|
2271 |
#如果沒有符合格式
|
| - |
|
2272 |
if($findSpecifyStrFormat["found"]==="false"){
|
| - |
|
2273 |
|
| - |
|
2274 |
#跳過該行
|
| - |
|
2275 |
continue;
|
| - |
|
2276 |
|
| - |
|
2277 |
}#if end
|
| - |
|
2278 |
|
| - |
|
2279 |
#儲存時間點
|
| - |
|
2280 |
$info["time"]=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
|
| - |
|
2281 |
|
| - |
|
2282 |
#儲存ip
|
| - |
|
2283 |
$info["ip"]=$findSpecifyStrFormat["parsedVar"]["ip"][0];
|
| - |
|
2284 |
|
| - |
|
2285 |
#儲存log
|
| - |
|
2286 |
$info["log"]=$oriLog;
|
| - |
|
2287 |
|
| - |
|
2288 |
#儲存查詢的目標
|
| - |
|
2289 |
$info["queryTarget"]=$findSpecifyStrFormat["parsedVar"]["queryTarget"][0];
|
| - |
|
2290 |
|
| - |
|
2291 |
#儲存疑似有問題的ip
|
| - |
|
2292 |
$ips_named[$info["ip"]][]=$info;
|
| - |
|
2293 |
|
| - |
|
2294 |
}#foreach end
|
| - |
|
2295 |
|
| - |
|
2296 |
#針對每個可能有問題ip的每個log行
|
| - |
|
2297 |
foreach($ips_named as $ip => $infos){
|
| - |
|
2298 |
|
| - |
|
2299 |
#初始化記錄ip來訪不大於1分鐘的計數
|
| - |
|
2300 |
$count=0;
|
| - |
|
2301 |
|
| - |
|
2302 |
#初始化記錄歷史log跟time
|
| - |
|
2303 |
$history=array();
|
| - |
|
2304 |
|
| - |
|
2305 |
#針對每個log行資訊
|
| - |
|
2306 |
foreach($infos as $index => $info){
|
| - |
|
2307 |
|
| - |
|
2308 |
#unixtime
|
| - |
|
2309 |
$time=strtotime($info["time"]);
|
| - |
|
2310 |
|
| - |
|
2311 |
#如果沒有下筆記錄
|
| - |
|
2312 |
if(!isset($infos[$index+1])){
|
| - |
|
2313 |
|
| - |
|
2314 |
#結束 foreach
|
| - |
|
2315 |
break;
|
| - |
|
2316 |
|
| - |
|
2317 |
}#if end
|
| - |
|
2318 |
|
| - |
|
2319 |
#取得unixtime
|
| - |
|
2320 |
$next_time=strtotime($infos[$index+1]["time"]);
|
| - |
|
2321 |
|
| - |
|
2322 |
#如果時間間隔大於60秒
|
| - |
|
2323 |
if($next_time-$time>60){
|
| - |
|
2324 |
|
| - |
|
2325 |
#跳過,看下筆記錄
|
| - |
|
2326 |
continue;
|
| - |
|
2327 |
|
| - |
|
2328 |
}#if end
|
| - |
|
2329 |
|
| - |
|
2330 |
#計數+1
|
| - |
|
2331 |
$count++;
|
| - |
|
2332 |
|
| - |
|
2333 |
#記錄歷史資訊
|
| - |
|
2334 |
$history[]=array("time"=>$time,"log"=>$info["log"]);
|
| - |
|
2335 |
|
| - |
|
2336 |
}#foreach end
|
| - |
|
2337 |
|
| - |
|
2338 |
#如果有達到3次
|
| - |
|
2339 |
if($count>=3){
|
| - |
|
2340 |
|
| - |
|
2341 |
#初始化暫存的陣列
|
| - |
|
2342 |
$tmp=array();
|
| - |
|
2343 |
|
| - |
|
2344 |
#設置ip
|
| - |
|
2345 |
$tmp["ip"]=$ip;
|
| - |
|
2346 |
|
| - |
|
2347 |
#設置info
|
| - |
|
2348 |
$tmp["info"]=$history;
|
| - |
|
2349 |
|
| - |
|
2350 |
#記錄攻擊者的IP
|
| - |
|
2351 |
$attacker_ips_namd[]=$tmp;
|
| - |
|
2352 |
|
| - |
|
2353 |
}#if end
|
| - |
|
2354 |
|
| - |
|
2355 |
}#foreach end
|
| - |
|
2356 |
|
| - |
|
2357 |
}#if end
|
| - |
|
2358 |
|
| - |
|
2359 |
#設置結果
|
| - |
|
2360 |
$result["content"]=$attacker_ips_namd;
|
| - |
|
2361 |
|
| - |
|
2362 |
#設置執行正常
|
| - |
|
2363 |
$result["status"]="true";
|
| - |
|
2364 |
|
| - |
|
2365 |
#回傳結果
|
| - |
|
2366 |
return $result;
|
| - |
|
2367 |
|
| - |
|
2368 |
}#function checkNamedAttackLog end
|
| - |
|
2369 |
|
| - |
|
2370 |
/*
|
| - |
|
2371 |
#函式說明:
|
| - |
|
2372 |
#檢查 dovecot log 中疑似攻擊的記錄.
|
| - |
|
2373 |
#回傳結果:
|
| - |
|
2374 |
#$result["status"],字串,執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
2375 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
2376 |
#$result["function"],字串,當前執行的函式名稱.
|
| - |
|
2377 |
#$result["content"],陣列,攻擊記錄資訊,每個元素為陣列key為"ip"者為攻擊者的ip;key為info者為其資訊陣列,其key為"log"者代表log的行內容;key為"time"者代表時間點;key為ip者代表ip.
|
| - |
|
2378 |
#必填參數:
|
| - |
|
2379 |
#無.
|
| - |
|
2380 |
#可省略參數:
|
| - |
|
2381 |
#無
|
| - |
|
2382 |
#參考資料:
|
| - |
|
2383 |
#無.
|
| - |
|
2384 |
#備註:
|
| - |
|
2385 |
#無.
|
| - |
|
2386 |
*/
|
| - |
|
2387 |
public static function checkDovecotAttackLog(){
|
| - |
|
2388 |
|
| - |
|
2389 |
#初始化要回傳的結果
|
| - |
|
2390 |
$result=array();
|
| - |
|
2391 |
|
| - |
|
2392 |
#取得當前執行的函數名稱
|
| - |
|
2393 |
$result["function"]=__FUNCTION__;
|
| - |
|
2394 |
|
| - |
|
2395 |
#透過 journalctl -a -e --unit=dovecot.service 來取得 IP
|
| - |
|
2396 |
#函式說明:
|
| - |
|
2397 |
#呼叫shell執行系統命令,並取得回傳的內容.
|
| - |
|
2398 |
#回傳的結果:
|
| - |
|
2399 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
2400 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
2401 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
2402 |
#$result["argu"],使用的參數.
|
| - |
|
2403 |
#$result["cmd"],執行的指令內容.
|
| - |
|
2404 |
#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
2405 |
#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
|
| - |
|
2406 |
#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
2407 |
#$result["running"],是否還在執行.
|
| - |
|
2408 |
#$result["pid"],pid.
|
| - |
|
2409 |
#$result["statusCode"],執行結束後的代碼.
|
| - |
|
2410 |
#必填參數:
|
| - |
|
2411 |
#$conf["command"],字串,要執行的指令與.
|
| - |
|
2412 |
$conf["external::callShell"]["command"]="journalctl";
|
| - |
|
2413 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
| - |
|
2414 |
$conf["external::callShell"]["fileArgu"]=__FILE__;
|
| - |
|
2415 |
#可省略參數:
|
| - |
|
2416 |
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
|
| - |
|
2417 |
$conf["external::callShell"]["argu"]=array("-a","-e","--unit=dovecot.service");
|
| - |
|
2418 |
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
|
| - |
|
2419 |
#$conf["arguIsAddr"]=array();
|
| - |
|
2420 |
#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
|
| - |
|
2421 |
#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
|
| - |
|
2422 |
#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
|
| - |
|
2423 |
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
|
| - |
|
2424 |
#$conf["enablePrintDescription"]="true";
|
| - |
|
2425 |
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
|
| - |
|
2426 |
#$conf["printDescription"]="";
|
| - |
|
2427 |
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
|
| - |
|
2428 |
$conf["external::callShell"]["escapeshellarg"]="true";
|
| - |
|
2429 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
| - |
|
2430 |
#$conf["username"]="";
|
| - |
|
2431 |
#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
| - |
|
2432 |
#$conf["password"]="";
|
| - |
|
2433 |
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
|
| - |
|
2434 |
#$conf["useScript"]="";
|
| - |
|
2435 |
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
|
| - |
|
2436 |
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
|
| - |
|
2437 |
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
|
| - |
|
2438 |
#$conf["inBackGround"]="";
|
| - |
|
2439 |
#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
|
| - |
|
2440 |
#$conf["getErr"]="false";
|
| - |
|
2441 |
#備註:
|
| - |
|
2442 |
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
|
| - |
|
2443 |
#參考資料:
|
| - |
|
2444 |
#exec=>http://php.net/manual/en/function.exec.php
|
| - |
|
2445 |
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
|
| - |
|
2446 |
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
|
| - |
|
2447 |
$callShell=external::callShell($conf["external::callShell"]);
|
| - |
|
2448 |
unset($conf["external::callShell"]);
|
| - |
|
2449 |
|
| - |
|
2450 |
#如果執行失敗
|
| - |
|
2451 |
if($callShell["status"]==="false"){
|
| - |
|
2452 |
|
| - |
|
2453 |
#如果有 statusCode
|
| - |
|
2454 |
if(isset($callShell["statusCode"])){
|
| - |
|
2455 |
|
| - |
|
2456 |
#如果shell回傳不為0也不為1
|
| - |
|
2457 |
if($callShell["statusCode"]!==0 && $callShell["statusCode"]!==1){
|
| - |
|
2458 |
|
| - |
|
2459 |
#設置執行失敗
|
| - |
|
2460 |
$result["status"]="false";
|
| - |
|
2461 |
|
| - |
|
2462 |
#設置錯誤訊息
|
| - |
|
2463 |
$result["error"]=$callShell;
|
| - |
|
2464 |
|
| - |
|
2465 |
#回傳結果
|
| - |
|
2466 |
return $result;
|
| - |
|
2467 |
|
| - |
|
2468 |
}#if end
|
| - |
|
2469 |
|
| - |
|
2470 |
}#if end
|
| - |
|
2471 |
|
| - |
|
2472 |
#設置執行失敗
|
| - |
|
2473 |
$result["status"]="false";
|
| - |
|
2474 |
|
| - |
|
2475 |
#設置錯誤訊息
|
| - |
|
2476 |
$result["error"]=$callShell;
|
| - |
|
2477 |
|
| - |
|
2478 |
#回傳結果
|
| - |
|
2479 |
return $result;
|
| - |
|
2480 |
|
| - |
|
2481 |
}#if end
|
| - |
|
2482 |
|
| - |
|
2483 |
#記錄攻擊者的IP
|
| - |
|
2484 |
$attacker_ips_imap=array();
|
| - |
|
2485 |
|
| - |
|
2486 |
/* $callShell["output"] 範例截取結果
|
| - |
|
2487 |
Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<MxQuPu+73xpliNc9>
|
| - |
|
2488 |
Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<hH8xPu+7dBtliNc9>
|
| - |
|
2489 |
Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<nmI0Pu+7zhtliNc9>
|
| - |
|
2490 |
Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<1GU2Pu+7NBhliNc9>
|
| - |
|
2491 |
Feb 23 00:24:59 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<0Io5Pu+7sRhliNc9>
|
| - |
|
2492 |
Feb 23 00:24:59 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<zbQ+Pu+7rhlliNc9>
|
| - |
|
2493 |
Feb 23 00:24:59 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<0P5APu+7/BlliNc9>
|
| - |
|
2494 |
Feb 23 00:24:59 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<gKRDPu+7XhpliNc9>
|
| - |
|
2495 |
Feb 23 00:24:59 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<4hNHPu+77hpliNc9>
|
| - |
|
2496 |
Feb 23 00:25:00 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<belIPu+7bBtliNc9>
|
| - |
|
2497 |
Feb 23 00:25:00 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<VhRLPu+7xBtliNc9>
|
| - |
|
2498 |
Feb 23 00:46:19 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<loiMiu+7cxhliNc9>
|
| - |
|
2499 |
Feb 23 00:46:19 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<RNCQiu+7/xhliNc9>
|
| - |
|
2500 |
Feb 23 00:46:20 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<NWCTiu+7PBlliNc9>
|
| - |
|
2501 |
Feb 23 00:46:20 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<2tiViu+7hBlliNc9>
|
| - |
|
2502 |
Feb 23 00:46:20 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<w6Sbiu+7/xlliNc9>
|
| - |
|
2503 |
Feb 23 00:46:21 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<SkWkiu+7gBtliNc9>
|
| - |
|
2504 |
Feb 23 00:46:21 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<bGCmiu+7qBtliNc9>
|
| - |
|
2505 |
Feb 23 00:46:21 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<0E+oiu+76RtliNc9>
|
| - |
|
2506 |
Feb 23 00:46:21 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<FBGriu+7UhhliNc9>
|
| - |
|
2507 |
Feb 23 00:46:21 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<AeSsiu+7iBhliNc9>
|
| - |
|
2508 |
Feb 23 00:46:21 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<gpSuiu+70hhliNc9>
|
| - |
|
2509 |
Feb 23 01:40:38 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<zYfITPC7RBlliNc9>
|
| - |
|
2510 |
Feb 23 01:40:38 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<GULMTPC7zhlliNc9>
|
| - |
|
2511 |
Feb 23 01:40:38 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<3jjOTPC7CBpliNc9>
|
| - |
|
2512 |
Feb 23 01:40:38 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<vhHQTPC7UBpliNc9>
|
| - |
|
2513 |
Feb 23 01:40:38 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<vArTTPC7rxpliNc9>
|
| - |
|
2514 |
Feb 23 01:40:39 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<hDTXTPC7GhtliNc9>
|
| - |
|
2515 |
Feb 23 01:40:39 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<c6vZTPC7SRtliNc9>
|
| - |
|
2516 |
Feb 23 01:40:39 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<rQzcTPC7jBtliNc9>
|
| - |
|
2517 |
Feb 23 01:40:39 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<LSffTPC78htliNc9>
|
| - |
|
2518 |
Feb 23 01:40:39 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<XLThTPC7KBhliNc9>
|
| - |
|
2519 |
Feb 23 01:40:40 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<tZfjTPC7dxhliNc9>
|
| - |
|
2520 |
Feb 23 03:27:10 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<i3bIyfG7AxtliNc9>
|
| - |
|
2521 |
Feb 23 03:27:11 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<0sLVyfG7uxtliNc9>
|
| - |
|
2522 |
Feb 23 03:27:11 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<BJXZyfG7BhhliNc9>
|
| - |
|
2523 |
Feb 23 03:27:11 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<xK3cyfG7SxhliNc9>
|
| - |
|
2524 |
Feb 23 03:27:12 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<q43gyfG7aRhliNc9>
|
| - |
|
2525 |
Feb 23 03:27:12 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<Oj3syfG7FBlliNc9>
|
| - |
|
2526 |
Feb 23 03:27:12 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<SF7uyfG7RhlliNc9>
|
| - |
|
2527 |
Feb 23 03:27:13 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<IM/wyfG7ZRlliNc9>
|
| - |
|
2528 |
Feb 23 03:27:13 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<pXv1yfG7vBlliNc9>
|
| - |
|
2529 |
Feb 23 03:27:13 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<8ub4yfG7/xlliNc9>
|
| - |
|
2530 |
Feb 23 03:27:13 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<H0j7yfG7NRpliNc9>
|
| - |
|
2531 |
Feb 23 06:10:07 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<Zw6FEPS7WxhliNc9>
|
| - |
|
2532 |
Feb 23 06:10:08 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<vmKTEPS7cRpliNc9>
|
| - |
|
2533 |
Feb 23 06:10:08 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<SkOXEPS7BxtliNc9>
|
| - |
|
2534 |
Feb 23 06:10:08 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<H42bEPS7WRtliNc9>
|
| - |
|
2535 |
Feb 23 06:10:09 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<jFqoEPS7SRhliNc9>
|
| - |
|
2536 |
Feb 23 06:10:10 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<TNy4EPS7DhpliNc9>
|
| - |
|
2537 |
Feb 23 06:10:10 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<JYW7EPS7mBpliNc9>
|
| - |
|
2538 |
Feb 23 06:10:10 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=</Ve+EPS76hpliNc9>
|
| - |
|
2539 |
Feb 23 06:10:11 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<StLGEPS7qhtliNc9>
|
| - |
|
2540 |
Feb 23 06:10:11 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<7RnLEPS7DBhliNc9>
|
| - |
|
2541 |
Feb 23 06:10:11 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<6xTOEPS7eBhliNc9>
|
| - |
|
2542 |
Feb 23 06:29:27 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<YHy0VfS7uBhliNc9>
|
| - |
|
2543 |
Feb 23 06:29:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<WLW4VfS7fxlliNc9>
|
| - |
|
2544 |
Feb 23 06:29:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<lM66VfS73BlliNc9>
|
| - |
|
2545 |
Feb 23 06:29:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<Q4K9VfS7NxpliNc9>
|
| - |
|
2546 |
Feb 23 06:29:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<JiLBVfS7rRpliNc9>
|
| - |
|
2547 |
Feb 23 06:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<DETIVfS7qxtliNc9>
|
| - |
|
2548 |
Feb 23 06:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<UlLLVfS7GhhliNc9>
|
| - |
|
2549 |
Feb 23 06:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<safNVfS7txhliNc9>
|
| - |
|
2550 |
Feb 23 06:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<M/DQVfS7LxlliNc9>
|
| - |
|
2551 |
Feb 23 06:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<+zPTVfS7eRlliNc9>
|
| - |
|
2552 |
Feb 23 06:29:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<dxXWVfS72hlliNc9>
|
| - |
|
2553 |
Feb 23 06:44:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<S0pci/S7SxhliNc9>
|
| - |
|
2554 |
Feb 23 06:44:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<zThji/S78RhliNc9>
|
| - |
|
2555 |
Feb 23 06:44:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<8PJoi/S7ixlliNc9>
|
| - |
|
2556 |
Feb 23 06:44:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<Qkhui/S7PBpliNc9>
|
| - |
|
2557 |
Feb 23 06:44:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<SXVzi/S7hhtliNc9>
|
| - |
|
2558 |
Feb 23 06:44:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=</X55i/S7uhhliNc9>
|
| - |
|
2559 |
Feb 23 06:44:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<MHJ9i/S74hlliNc9>
|
| - |
|
2560 |
Feb 23 06:44:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<RBWBi/S7pRpliNc9>
|
| - |
|
2561 |
Feb 23 06:44:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<NJeGi/S7yhtliNc9>
|
| - |
|
2562 |
Feb 23 06:44:31 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<QsaMi/S7rxhliNc9>
|
| - |
|
2563 |
Feb 23 06:44:31 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<8fiPi/S7uBlliNc9>
|
| - |
|
2564 |
Feb 23 07:01:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<dt04yPS7KBlliNc9>
|
| - |
|
2565 |
Feb 23 07:01:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<ZMI9yPS7WxpliNc9>
|
| - |
|
2566 |
Feb 23 07:01:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<nTVAyPS7ARtliNc9>
|
| - |
|
2567 |
Feb 23 07:01:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<wj1CyPS7lxtliNc9>
|
| - |
|
2568 |
Feb 23 07:01:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<u7RFyPS7YRhliNc9>
|
| - |
|
2569 |
Feb 23 07:01:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<tpBLyPS7ZhlliNc9>
|
| - |
|
2570 |
Feb 23 07:01:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<CRdOyPS7wxlliNc9>
|
| - |
|
2571 |
Feb 23 07:01:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<v9NQyPS7JxpliNc9>
|
| - |
|
2572 |
Feb 23 07:01:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<81lUyPS73hpliNc9>
|
| - |
|
2573 |
Feb 23 07:01:31 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<PCZXyPS7TRtliNc9>
|
| - |
|
2574 |
Feb 23 07:01:31 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<VnNZyPS7qxtliNc9>
|
| - |
|
2575 |
Feb 23 07:14:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<op+l9vS7ZxhliNc9>
|
| - |
|
2576 |
Feb 23 07:14:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<aBCr9vS7CBlliNc9>
|
| - |
|
2577 |
Feb 23 07:14:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<0sOt9vS7dRlliNc9>
|
| - |
|
2578 |
Feb 23 07:14:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<NFaw9vS7xhlliNc9>
|
| - |
|
2579 |
Feb 23 07:14:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<QS609vS7SRpliNc9>
|
| - |
|
2580 |
Feb 23 07:14:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<4FW79vS76htliNc9>
|
| - |
|
2581 |
Feb 23 07:14:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<Fxu+9vS7gBhliNc9>
|
| - |
|
2582 |
Feb 23 07:14:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<3djA9vS75RhliNc9>
|
| - |
|
2583 |
Feb 23 07:14:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<hgzE9vS7mxlliNc9>
|
| - |
|
2584 |
Feb 23 07:14:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<J8TG9vS7GBpliNc9>
|
| - |
|
2585 |
Feb 23 07:14:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<t87I9vS7mBpliNc9>
|
| - |
|
2586 |
Feb 23 07:29:27 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<1xBILPW7MRtliNc9>
|
| - |
|
2587 |
Feb 23 07:29:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<IXZNLPW79htliNc9>
|
| - |
|
2588 |
Feb 23 07:29:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<6OdPLPW7chhliNc9>
|
| - |
|
2589 |
Feb 23 07:29:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<M5BSLPW78hhliNc9>
|
| - |
|
2590 |
Feb 23 07:29:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<Nv9VLPW7UxlliNc9>
|
| - |
|
2591 |
Feb 23 07:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<foJbLPW7KRpliNc9>
|
| - |
|
2592 |
Feb 23 07:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<EoVeLPW7nxpliNc9>
|
| - |
|
2593 |
Feb 23 07:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<DwNhLPW7JRtliNc9>
|
| - |
|
2594 |
Feb 23 07:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<mKhkLPW7ohtliNc9>
|
| - |
|
2595 |
Feb 23 07:29:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<3nhnLPW7/htliNc9>
|
| - |
|
2596 |
Feb 23 07:29:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<e+lpLPW7XRhliNc9>
|
| - |
|
2597 |
Feb 23 07:44:27 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<KtTtYfW7dBhliNc9>
|
| - |
|
2598 |
Feb 23 07:44:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<MLTxYfW77BhliNc9>
|
| - |
|
2599 |
Feb 23 07:44:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<9GL0YfW7KBlliNc9>
|
| - |
|
2600 |
Feb 23 07:44:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<JNT2YfW7fRlliNc9>
|
| - |
|
2601 |
Feb 23 07:44:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<8Zv5YfW72RlliNc9>
|
| - |
|
2602 |
Feb 23 07:44:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<lbv/YfW73BpliNc9>
|
| - |
|
2603 |
Feb 23 07:44:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<5zsCYvW7EBtliNc9>
|
| - |
|
2604 |
Feb 23 07:44:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<aE8EYvW7bRtliNc9>
|
| - |
|
2605 |
Feb 23 07:44:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<LEIHYvW75RtliNc9>
|
| - |
|
2606 |
Feb 23 07:44:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<rLsJYvW7MRhliNc9>
|
| - |
|
2607 |
Feb 23 07:44:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<9oMMYvW7ihhliNc9>
|
| - |
|
2608 |
Feb 23 07:59:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<x7SUl/W7mBpliNc9>
|
| - |
|
2609 |
Feb 23 07:59:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<k1KZl/W73xtliNc9>
|
| - |
|
2610 |
Feb 23 07:59:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<Veabl/W7PxhliNc9>
|
| - |
|
2611 |
Feb 23 07:59:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<Yamel/W7sxhliNc9>
|
| - |
|
2612 |
Feb 23 07:59:28 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<wpGil/W7OBlliNc9>
|
| - |
|
2613 |
Feb 23 07:59:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<+VCol/W7aBpliNc9>
|
| - |
|
2614 |
Feb 23 07:59:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<TMaql/W7zhpliNc9>
|
| - |
|
2615 |
Feb 23 07:59:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<KnKtl/W7GBtliNc9>
|
| - |
|
2616 |
Feb 23 07:59:29 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<Lkixl/W7ixtliNc9>
|
| - |
|
2617 |
Feb 23 07:59:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<8bWzl/W7ARhliNc9>
|
| - |
|
2618 |
Feb 23 07:59:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<70q2l/W7PBhliNc9>
|
| - |
|
2619 |
Sep 29 06:53:42 qbpwcf.org dovecot[98]: imap-login: Disconnected: Connection closed (no auth attempts in 0 secs): user=<>, rip=3.231.151.171, lip=169.254.2.1, TLS, session=<MaKQGOs/wIMD55er>
|
| - |
|
2620 |
Sep 29 07:42:58 qbpwcf.org auth[3737748]: pam_unix(dovecot:auth): check pass; user unknown
|
| - |
|
2621 |
Sep 29 07:42:58 qbpwcf.org auth[3737748]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=account@qbpwcf.org rhost=62.60.131.29
|
| - |
|
2622 |
Sep 29 08:10:02 qbpwcf.org dovecot[98]: imap(liveuser)<3755807><SvyIKew/xLpyIuFn>: Disconnected: Connection closed (UID SEARCH finished 0.039 secs ago) in=119 out=1504 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
|
| - |
|
2623 |
Sep 29 08:12:02 qbpwcf.org dovecot[98]: imap-login: Login: user=<liveuser>, method=PLAIN, rip=149.102.158.38, lip=169.254.2.1, mpid=3757116, TLS, session=<B2O9MOw/TrmVZp4m>
|
| - |
|
2624 |
Sep 29 08:12:04 qbpwcf.org dovecot[98]: imap(liveuser)<3757116><B2O9MOw/TrmVZp4m>: Disconnected: Logged out in=240 out=21891 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
|
| - |
|
2625 |
Sep 29 08:12:06 qbpwcf.org dovecot[98]: imap-login: Login: user=<liveuser>, method=PLAIN, rip=149.102.158.38, lip=169.254.2.1, mpid=3757144, TLS, session=<S0rwMOw/XLmVZp4m>
|
| - |
|
2626 |
Sep 29 08:12:09 qbpwcf.org dovecot[98]: imap(liveuser)<3757144><S0rwMOw/XLmVZp4m>: Disconnected: Logged out in=885 out=25454 deleted=0 expunged=0 trashed=0 hdr_count=2 hdr_bytes=21658 body_count=0 body_bytes=0
|
| - |
|
2627 |
Sep 29 08:28:48 qbpwcf.org dovecot[98]: imap-login: Login: user=<liveuser>, method=PLAIN, rip=114.34.225.103, lip=169.254.2.1, mpid=3768144, TLS, session=<Gk6ybOw/nNpyIuFn>
|
| - |
|
2628 |
Sep 29 08:28:51 qbpwcf.org dovecot[98]: imap(liveuser)<3768144><Gk6ybOw/nNpyIuFn>: Disconnected: Connection closed (LIST finished 1.939 secs ago) in=50 out=17609 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
|
| - |
|
2629 |
Sep 29 08:28:51 qbpwcf.org dovecot[98]: imap-login: Login: user=<liveuser>, method=PLAIN, rip=114.34.225.103, lip=169.254.2.1, mpid=3768149, TLS, session=<ct7bbOw/qtpyIuFn>
|
| - |
|
2630 |
Sep 29 08:28:52 qbpwcf.org dovecot[98]: imap(liveuser)<3768149><ct7bbOw/qtpyIuFn>: Disconnected: Connection closed (UID FETCH finished 0.045 secs ago) in=196 out=2381 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
|
| - |
|
2631 |
Sep 29 08:28:53 qbpwcf.org dovecot[98]: imap-login: Login: user=<liveuser>, method=PLAIN, rip=114.34.225.103, lip=169.254.2.1, mpid=3768155, TLS, session=<DvP1bOw/tNpyIuFn>
|
| - |
|
2632 |
Sep 29 08:28:55 qbpwcf.org dovecot[98]: imap(liveuser)<3768155><DvP1bOw/tNpyIuFn>: Disconnected: Connection closed (UID SEARCH finished 0.180 secs ago) in=119 out=1504 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
|
| - |
|
2633 |
Sep 29 08:39:24 qbpwcf.org auth[3775219]: pam_unix(dovecot:auth): check pass; user unknown
|
| - |
|
2634 |
Sep 29 08:39:24 qbpwcf.org auth[3775219]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=test rhost=196.251.92.78
|
| - |
|
2635 |
Sep 29 08:40:44 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): check pass; user unknown
|
| - |
|
2636 |
Sep 29 08:40:44 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=1q2w3e4r5t4567 rhost=158.94.208.72
|
| - |
|
2637 |
Sep 29 08:41:18 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): check pass; user unknown
|
| - |
|
2638 |
Sep 29 08:41:18 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=spam rhost=62.60.130.148
|
| - |
|
2639 |
*/
|
| - |
|
2640 |
|
| - |
|
2641 |
#認證失敗的關鍵字
|
| - |
|
2642 |
$keyWordAF="authentication failure";
|
| - |
|
2643 |
|
| - |
|
2644 |
#未認證或SSL錯誤
|
| - |
|
2645 |
$keyWordNAA="no auth attempts";
|
| - |
|
2646 |
|
| - |
|
2647 |
#搜尋符合關鍵字的log行
|
| - |
|
2648 |
#函式說明:
|
| - |
|
2649 |
#檢查多個字串中的每個字串是否有多個關鍵字
|
| - |
|
2650 |
#回傳結果:
|
| - |
|
2651 |
#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
|
| - |
|
2652 |
#$result["function"],當前執行的函數名稱.
|
| - |
|
2653 |
#$result["error"],錯誤訊息.
|
| - |
|
2654 |
#$result["argu"],使用的參數.
|
| - |
|
2655 |
#$result["foundedTrueKey"],結果為"true"的被搜尋元素key陣列,與其數值內容.
|
| - |
|
2656 |
#$result["foundedKeyWords"],找到的關鍵字陣列.
|
| - |
|
2657 |
#$result["foundedFalseKey"],結果為"false"的被搜尋元素key陣列,與其數值內容.
|
| - |
|
2658 |
#$result["foundedTrueKeyWords"],二維陣列,各個字串有找到的關鍵字陣列.
|
| - |
|
2659 |
#$result["foundedAll"],是否每個關鍵字都有找到,"true"代表每個都有找到,"false"代表沒有每個都找到.
|
| - |
|
2660 |
#$result["keyWordsIncludeStr"],陣列,儲存有找到關鍵字的來源的索引(sourceIndex)與其內容(sourceVal)跟找到的關鍵字項目陣列(KeyWords).
|
| - |
|
2661 |
#必填參數:
|
| - |
|
2662 |
#$conf["keyWords"],字串陣列,想要搜尋的關鍵字.
|
| - |
|
2663 |
$conf["search::findManyKeyWordsFromManyString"]["keyWords"]=array($keyWordAF,$keyWordNAA);
|
| - |
|
2664 |
#$conf["stringArray"],字串陣列,要被搜尋的字串內容陣列.
|
| - |
|
2665 |
$conf["search::findManyKeyWordsFromManyString"]["stringArray"]=$callShell["output"];
|
| - |
|
2666 |
#可省略參數:
|
| - |
|
2667 |
#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為"false"不需要完全符合.
|
| - |
|
2668 |
#$conf["completeEqual"]="true";
|
| - |
|
2669 |
#參考資料:
|
| - |
|
2670 |
#無.
|
| - |
|
2671 |
#備註:
|
| - |
|
2672 |
#無.
|
| - |
|
2673 |
$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
|
| - |
|
2674 |
unset($conf["search::findManyKeyWordsFromManyString"]);
|
| - |
|
2675 |
|
| - |
|
2676 |
#如果執行失敗
|
| - |
|
2677 |
if($findManyKeyWordsFromManyString["status"]==="false"){
|
| - |
|
2678 |
|
| - |
|
2679 |
#設置執行失敗
|
| - |
|
2680 |
$result["status"]="false";
|
| - |
|
2681 |
|
| - |
|
2682 |
#設置錯誤訊息
|
| - |
|
2683 |
$result["error"]=$findManyKeyWordsFromManyString;
|
| - |
|
2684 |
|
| - |
|
2685 |
#回傳結果
|
| - |
|
2686 |
return $result;
|
| - |
|
2687 |
|
| - |
|
2688 |
}#if end
|
| - |
|
2689 |
|
| - |
|
2690 |
#初始化儲存可能有問題的存取Dovecot服務遠端ip
|
| - |
|
2691 |
$rickyIpsOfDocecot=array();
|
| - |
|
2692 |
|
| - |
|
2693 |
#針對每個符合的log行
|
| - |
|
2694 |
foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $index => $oriLog){
|
| - |
|
2695 |
|
| - |
|
2696 |
#找到的關鍵字
|
| - |
|
2697 |
$foundKeyWord=$findManyKeyWordsFromManyString["foundedTrueKeyWords"][$index][0];
|
| - |
|
2698 |
|
| - |
|
2699 |
#依照符合的關鍵字
|
| - |
|
2700 |
switch($foundKeyWord){
|
| - |
|
2701 |
|
| - |
|
2702 |
#如果是認證失敗
|
| - |
|
2703 |
case $keyWordAF:
|
| - |
|
2704 |
|
| - |
|
2705 |
#範例
|
| - |
|
2706 |
#Sep 29 08:41:18 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=spam rhost=62.60.130.148
|
| - |
|
2707 |
#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} : authentication failure; logname=${account} ${doNotNeed} rhost=${ip}
|
| - |
|
2708 |
|
| - |
|
2709 |
#取得時間點跟遠端IP
|
| - |
|
2710 |
#函式說明:
|
| - |
|
2711 |
#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
|
| - |
|
2712 |
#回傳結果:
|
| - |
|
2713 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
2714 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
2715 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
2716 |
#$result["argu"],所使用的參數.
|
| - |
|
2717 |
#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
|
| - |
|
2718 |
#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
|
| - |
|
2719 |
#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
|
| - |
|
2720 |
#必填參數:
|
| - |
|
2721 |
#$conf["input"],字串,要檢查的字串.
|
| - |
|
2722 |
$conf["search::findSpecifyStrFormat"]["input"]=$oriLog;
|
| - |
|
2723 |
#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
|
| - |
|
2724 |
$conf["search::findSpecifyStrFormat"]["format"]="\${month} \${day} \${hour}:\${min}:\${sec} \${doNotNeed} : authentication failure; logname=\${account} \${doNotNeed} rhost=\${ip}";
|
| - |
|
2725 |
#可省略參數:
|
| - |
|
2726 |
#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
|
| - |
|
2727 |
#$conf["search::findSpecifyStrFormat"]["varEqual"]=array(null,"found");
|
| - |
|
2728 |
#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
|
| - |
|
2729 |
#$conf["varCon"]=array("no_tail"=>" not");
|
| - |
|
2730 |
#參考資料:
|
| - |
|
2731 |
#無.
|
| - |
|
2732 |
#備註:
|
| - |
|
2733 |
#無.
|
| - |
|
2734 |
$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
|
| - |
|
2735 |
unset($conf["search::findSpecifyStrFormat"]);
|
| - |
|
2736 |
|
| - |
|
2737 |
#如果分割失敗
|
| - |
|
2738 |
if($findSpecifyStrFormat["status"]==="false"){
|
| - |
|
2739 |
|
| - |
|
2740 |
#設置執行失敗
|
| - |
|
2741 |
$result["status"]="false";
|
| - |
|
2742 |
|
| - |
|
2743 |
#設置錯誤訊息
|
| - |
|
2744 |
$result["error"]=$findSpecifyStrFormat;
|
| - |
|
2745 |
|
| - |
|
2746 |
#回傳結果
|
| - |
|
2747 |
return $result;
|
| - |
|
2748 |
|
| - |
|
2749 |
}#if end
|
| - |
|
2750 |
|
| - |
|
2751 |
#如果沒有符合格式
|
| - |
|
2752 |
if($findSpecifyStrFormat["found"]==="false"){
|
| - |
|
2753 |
|
| - |
|
2754 |
#跳過該行
|
| - |
|
2755 |
continue 2;
|
| - |
|
2756 |
|
| - |
|
2757 |
}#if end
|
| - |
|
2758 |
|
| - |
|
2759 |
#取得時間點
|
| - |
|
2760 |
$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
|
| - |
|
2761 |
|
| - |
|
2762 |
#取得ip
|
| - |
|
2763 |
$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
|
| - |
|
2764 |
|
| - |
|
2765 |
#儲存其資訊
|
| - |
|
2766 |
$rickyIpsOfDocecot[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
|
| - |
|
2767 |
|
| - |
|
2768 |
#跳出 switch
|
| - |
|
2769 |
break;
|
| - |
|
2770 |
|
| - |
|
2771 |
#如果是未認證或SSL錯誤
|
| - |
|
2772 |
case $keyWordNAA:
|
| - |
|
2773 |
|
| - |
|
2774 |
#範例
|
| - |
|
2775 |
#Feb 23 07:59:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<70q2l/W7PBhliNc9>
|
| - |
|
2776 |
#Sep 29 06:53:42 qbpwcf.org dovecot[98]: imap-login: Disconnected: Connection closed (no auth attempts in 0 secs): user=<>, rip=3.231.151.171, lip=169.254.2.1, TLS, session=<MaKQGOs/wIMD55er>
|
| - |
|
2777 |
#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} ( no auth attempts in ${doNotNeed} user=<${account}>, rip=${ip}, ${doNotNeed}
|
| - |
|
2778 |
|
| - |
|
2779 |
#取得時間點跟遠端IP
|
| - |
|
2780 |
#函式說明:
|
| - |
|
2781 |
#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
|
| - |
|
2782 |
#回傳結果:
|
| - |
|
2783 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
2784 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
2785 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
2786 |
#$result["argu"],所使用的參數.
|
| - |
|
2787 |
#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
|
| - |
|
2788 |
#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
|
| - |
|
2789 |
#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
|
| - |
|
2790 |
#必填參數:
|
| - |
|
2791 |
#$conf["input"],字串,要檢查的字串.
|
| - |
|
2792 |
$conf["search::findSpecifyStrFormat"]["input"]=$oriLog;
|
| - |
|
2793 |
#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
|
| - |
|
2794 |
$conf["search::findSpecifyStrFormat"]["format"]="\${month} \${day} \${hour}:\${min}:\${sec} \${doNotNeed} ( no auth attempts in \${doNotNeed} user=<\${account}>, rip=\${ip}, \${doNotNeed}";
|
| - |
|
2795 |
#可省略參數:
|
| - |
|
2796 |
#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
|
| - |
|
2797 |
#$conf["search::findSpecifyStrFormat"]["varEqual"]=array(null,"found");
|
| - |
|
2798 |
#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
|
| - |
|
2799 |
#$conf["varCon"]=array("no_tail"=>" not");
|
| - |
|
2800 |
#參考資料:
|
| - |
|
2801 |
#無.
|
| - |
|
2802 |
#備註:
|
| - |
|
2803 |
#無.
|
| - |
|
2804 |
$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
|
| - |
|
2805 |
unset($conf["search::findSpecifyStrFormat"]);
|
| - |
|
2806 |
|
| - |
|
2807 |
#如果分割失敗
|
| - |
|
2808 |
if($findSpecifyStrFormat["status"]==="false"){
|
| - |
|
2809 |
|
| - |
|
2810 |
#設置執行失敗
|
| - |
|
2811 |
$result["status"]="false";
|
| - |
|
2812 |
|
| - |
|
2813 |
#設置錯誤訊息
|
| - |
|
2814 |
$result["error"]=$findSpecifyStrFormat;
|
| - |
|
2815 |
|
| - |
|
2816 |
#回傳結果
|
| - |
|
2817 |
return $result;
|
| - |
|
2818 |
|
| - |
|
2819 |
}#if end
|
| - |
|
2820 |
|
| - |
|
2821 |
#如果沒有符合格式
|
| - |
|
2822 |
if($findSpecifyStrFormat["found"]==="false"){
|
| - |
|
2823 |
|
| - |
|
2824 |
#跳過該行
|
| - |
|
2825 |
continue 2;
|
| - |
|
2826 |
|
| - |
|
2827 |
}#if end
|
| - |
|
2828 |
|
| - |
|
2829 |
#取得時間點
|
| - |
|
2830 |
$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
|
| - |
|
2831 |
|
| - |
|
2832 |
#取得ip
|
| - |
|
2833 |
$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
|
| - |
|
2834 |
|
| - |
|
2835 |
#儲存其資訊
|
| - |
|
2836 |
$rickyIpsOfDocecot[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
|
| - |
|
2837 |
|
| - |
|
2838 |
#跳出 switch
|
| - |
|
2839 |
break;
|
| - |
|
2840 |
|
| - |
|
2841 |
#不應該執行到這邊
|
| - |
|
2842 |
default:
|
| - |
|
2843 |
|
| - |
|
2844 |
#設置執行失敗
|
| - |
|
2845 |
$result["status"]="false";
|
| - |
|
2846 |
|
| - |
|
2847 |
#設置錯誤訊息
|
| - |
|
2848 |
$result["error"][]="unexpected error";
|
| - |
|
2849 |
|
| - |
|
2850 |
#設置錯誤訊息
|
| - |
|
2851 |
$result["error"][]=$findManyKeyWordsFromManyString;
|
| - |
|
2852 |
|
| - |
|
2853 |
#回傳結果
|
| - |
|
2854 |
return $result;
|
| - |
|
2855 |
|
| - |
|
2856 |
}#switch end
|
| - |
|
2857 |
|
| - |
|
2858 |
}#foreach end
|
| - |
|
2859 |
|
| - |
|
2860 |
#初始化儲存可能有問題的ip資訊
|
| - |
|
2861 |
$risky_ips=array();
|
| - |
|
2862 |
|
| - |
|
2863 |
#針對每個ip
|
| - |
|
2864 |
foreach($rickyIpsOfDocecot as $ip => $info){
|
| - |
|
2865 |
|
| - |
|
2866 |
#如果同樣ip不到3次
|
| - |
|
2867 |
if(count($rickyIpsOfDocecot[$ip])<3){
|
| - |
|
2868 |
|
| - |
|
2869 |
#換看下個ip
|
| - |
|
2870 |
continue;
|
| - |
|
2871 |
|
| - |
|
2872 |
}#if end
|
| - |
|
2873 |
|
| - |
|
2874 |
#儲存可能有問題的ip資訊
|
| - |
|
2875 |
$risky_ips[]=$rickyIpsOfDocecot[$ip];
|
| - |
|
2876 |
|
| - |
|
2877 |
}#foreach end
|
| - |
|
2878 |
|
| - |
|
2879 |
#針對每個可能有問題ip的每個log行
|
| - |
|
2880 |
foreach($risky_ips as $ip => $infos){
|
| - |
|
2881 |
|
| - |
|
2882 |
#初始化暫存歷史資訊的陣列
|
| - |
|
2883 |
$history=array();
|
| - |
|
2884 |
|
| - |
|
2885 |
#初始化記錄ip來訪不大於1分鐘的計數
|
| - |
|
2886 |
$count=0;
|
| - |
|
2887 |
|
| - |
|
2888 |
#針對每個log行資訊
|
| - |
|
2889 |
foreach($infos as $index => $info){
|
| - |
|
2890 |
|
| - |
|
2891 |
#unixtime
|
| - |
|
2892 |
$time=strtotime($info["time"]);
|
| - |
|
2893 |
|
| - |
|
2894 |
#如果沒有下筆記錄
|
| - |
|
2895 |
if(!isset($infos[$index+1])){
|
| - |
|
2896 |
|
| - |
|
2897 |
#結束 foreach
|
| - |
|
2898 |
break;
|
| - |
|
2899 |
|
| - |
|
2900 |
}#if end
|
| - |
|
2901 |
|
| - |
|
2902 |
#取得unixtime
|
| - |
|
2903 |
$next_time=strtotime($infos[$index+1]["time"]);
|
| - |
|
2904 |
|
| - |
|
2905 |
#如果時間間隔大於60秒
|
| - |
|
2906 |
if($next_time-$time>60){
|
| - |
|
2907 |
|
| - |
|
2908 |
#跳過,看下筆記錄
|
| - |
|
2909 |
continue;
|
| - |
|
2910 |
|
| - |
|
2911 |
}#if end
|
| - |
|
2912 |
|
| - |
|
2913 |
#計數+1
|
| - |
|
2914 |
$count++;
|
| - |
|
2915 |
|
| - |
|
2916 |
#記錄該次事件資訊
|
| - |
|
2917 |
$history[]=array("time"=>$time,"log"=>$info["log"]);
|
| - |
|
2918 |
|
| - |
|
2919 |
}#foreach end
|
| - |
|
2920 |
|
| - |
|
2921 |
#如果有達到3次
|
| - |
|
2922 |
if($count>=3){
|
| - |
|
2923 |
|
| - |
|
2924 |
#初始化陣列
|
| - |
|
2925 |
$tmp=array();
|
| - |
|
2926 |
|
| - |
|
2927 |
#記錄ip
|
| - |
|
2928 |
$tmp["ip"]=$ip;
|
| - |
|
2929 |
|
| - |
|
2930 |
#記錄歷史資訊
|
| - |
|
2931 |
$tmp["info"]=$history;
|
| - |
|
2932 |
|
| - |
|
2933 |
#記錄攻擊者的IP
|
| - |
|
2934 |
$attacker_ips_imap[]=$ip;
|
| - |
|
2935 |
|
| - |
|
2936 |
}#if end
|
| - |
|
2937 |
|
| - |
|
2938 |
}#foreach end
|
| - |
|
2939 |
|
| - |
|
2940 |
#設置結果
|
| - |
|
2941 |
$result["content"]=$attacker_ips_imap;
|
| - |
|
2942 |
|
| - |
|
2943 |
#設置執行正常
|
| - |
|
2944 |
$result["status"]="true";
|
| - |
|
2945 |
|
| - |
|
2946 |
#回傳結果
|
| - |
|
2947 |
return $result;
|
| - |
|
2948 |
|
| - |
|
2949 |
}#function checkDovecotAttackLog end
|
| - |
|
2950 |
|
| - |
|
2951 |
/*
|
| - |
|
2952 |
#函式說明:
|
| - |
|
2953 |
#檢查 ssh log 中疑似攻擊的記錄.
|
| - |
|
2954 |
#回傳結果:
|
| - |
|
2955 |
#$result["status"],字串,執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
2956 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
2957 |
#$result["function"],字串,當前執行的函式名稱.
|
| - |
|
2958 |
#$result["content"],陣列,攻擊記錄資訊,每個元素為陣列key為"ip"者為攻擊者的ip;key為info者為其資訊陣列,其key為"log"者代表log的行內容;key為"time"者代表時間點;key為ip者代表ip.
|
| - |
|
2959 |
#必填參數:
|
| - |
|
2960 |
#無.
|
| - |
|
2961 |
#可省略參數:
|
| - |
|
2962 |
#無
|
| - |
|
2963 |
#參考資料:
|
| - |
|
2964 |
#無.
|
| - |
|
2965 |
#備註:
|
| - |
|
2966 |
#無.
|
| - |
|
2967 |
*/
|
| - |
|
2968 |
public static function checkSshAttackLog(){
|
| - |
|
2969 |
|
| - |
|
2970 |
#初始化要回傳的結果
|
| - |
|
2971 |
$result=array();
|
| - |
|
2972 |
|
| - |
|
2973 |
#取得當前執行的函數名稱
|
| - |
|
2974 |
$result["function"]=__FUNCTION__;
|
| - |
|
2975 |
|
| - |
|
2976 |
#記錄ssh攻擊者的IP
|
| - |
|
2977 |
$attacker_ips_ssh=array();
|
| - |
|
2978 |
|
| - |
|
2979 |
#透過 journalctl -a -e --unit=sshd.service來取得 ssh 攻擊者的 IP
|
| - |
|
2980 |
#函式說明:
|
| - |
|
2981 |
#呼叫shell執行系統命令,並取得回傳的內容.
|
| - |
|
2982 |
#回傳的結果:
|
| - |
|
2983 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
2984 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
2985 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
2986 |
#$result["argu"],使用的參數.
|
| - |
|
2987 |
#$result["cmd"],執行的指令內容.
|
| - |
|
2988 |
#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
2989 |
#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
|
| - |
|
2990 |
#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
2991 |
#$result["running"],是否還在執行.
|
| - |
|
2992 |
#$result["pid"],pid.
|
| - |
|
2993 |
#$result["statusCode"],執行結束後的代碼.
|
| - |
|
2994 |
#必填參數:
|
| - |
|
2995 |
#$conf["command"],字串,要執行的指令與.
|
| - |
|
2996 |
$conf["external::callShell"]["command"]="journalctl";
|
| - |
|
2997 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
| - |
|
2998 |
$conf["external::callShell"]["fileArgu"]=__FILE__;
|
| - |
|
2999 |
#可省略參數:
|
| - |
|
3000 |
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
|
| - |
|
3001 |
$conf["external::callShell"]["argu"]=array("-a","-e","--unit=sshd.service");
|
| - |
|
3002 |
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
|
| - |
|
3003 |
#$conf["arguIsAddr"]=array();
|
| - |
|
3004 |
#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
|
| - |
|
3005 |
#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
|
| - |
|
3006 |
#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
|
| - |
|
3007 |
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
|
| - |
|
3008 |
#$conf["enablePrintDescription"]="true";
|
| - |
|
3009 |
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
|
| - |
|
3010 |
#$conf["printDescription"]="";
|
| - |
|
3011 |
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
|
| - |
|
3012 |
$conf["external::callShell"]["escapeshellarg"]="true";
|
| - |
|
3013 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
| - |
|
3014 |
#$conf["username"]="";
|
| - |
|
3015 |
#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
| - |
|
3016 |
#$conf["password"]="";
|
| - |
|
3017 |
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
|
| - |
|
3018 |
#$conf["useScript"]="";
|
| - |
|
3019 |
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
|
| - |
|
3020 |
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
|
| - |
|
3021 |
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
|
| - |
|
3022 |
#$conf["inBackGround"]="";
|
| - |
|
3023 |
#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
|
| - |
|
3024 |
#$conf["getErr"]="false";
|
| - |
|
3025 |
#備註:
|
| - |
|
3026 |
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
|
| - |
|
3027 |
#參考資料:
|
| - |
|
3028 |
#exec=>http://php.net/manual/en/function.exec.php
|
| - |
|
3029 |
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
|
| - |
|
3030 |
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
|
| - |
|
3031 |
$callShell=external::callShell($conf["external::callShell"]);
|
| - |
|
3032 |
unset($conf["external::callShell"]);
|
| - |
|
3033 |
|
| - |
|
3034 |
#如果執行失敗
|
| - |
|
3035 |
if($callShell["status"]==="false"){
|
| - |
|
3036 |
|
| - |
|
3037 |
#如果有 statusCode
|
| - |
|
3038 |
if(isset($callShell["statusCode"])){
|
| - |
|
3039 |
|
| - |
|
3040 |
#如果shell回傳不為0也不為1
|
| - |
|
3041 |
if($callShell["statusCode"]!==0 && $callShell["statusCode"]!==1){
|
| - |
|
3042 |
|
| - |
|
3043 |
#設置執行失敗
|
| - |
|
3044 |
$result["status"]="false";
|
| - |
|
3045 |
|
| - |
|
3046 |
#設置錯誤訊息
|
| - |
|
3047 |
$result["error"]=$callShell;
|
| - |
|
3048 |
|
| - |
|
3049 |
#回傳結果
|
| - |
|
3050 |
return $result;
|
| - |
|
3051 |
|
| - |
|
3052 |
}#if end
|
| - |
|
3053 |
|
| - |
|
3054 |
}#if end
|
| - |
|
3055 |
|
| - |
|
3056 |
#設置執行失敗
|
| - |
|
3057 |
$result["status"]="false";
|
| - |
|
3058 |
|
| - |
|
3059 |
#設置錯誤訊息
|
| - |
|
3060 |
$result["error"]=$callShell;
|
| - |
|
3061 |
|
| - |
|
3062 |
#回傳結果
|
| - |
|
3063 |
return $result;
|
| - |
|
3064 |
|
| - |
|
3065 |
}#if end
|
| - |
|
3066 |
|
| - |
|
3067 |
/*
|
| - |
|
3068 |
得到的範例輸出
|
| - |
|
3069 |
Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: Invalid user lizepeng from 60.213.10.69 port 39156
|
| - |
|
3070 |
Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: pam_unix(sshd:auth): check pass; user unknown
|
| - |
|
3071 |
Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=60.213.10.69
|
| - |
|
3072 |
Sep 30 00:36:38 silverblue-guest.qbpwcf.org sshd-session[1607010]: Failed password for invalid user lizepeng from 60.213.10.69 port 39156 ssh2
|
| - |
|
3073 |
Sep 30 00:36:40 silverblue-guest.qbpwcf.org sshd-session[1607010]: Connection closed by invalid user lizepeng 60.213.10.69 port 39156 [preauth]
|
| - |
|
3074 |
Sep 30 05:54:01 silverblue-guest.qbpwcf.org sshd-session[2346022]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=60.213.10.81 user=root
|
| - |
|
3075 |
Sep 30 05:54:03 silverblue-guest.qbpwcf.org sshd-session[2346022]: Failed password for root from 60.213.10.81 port 41644 ssh2
|
| - |
|
3076 |
Sep 30 05:54:04 silverblue-guest.qbpwcf.org sshd-session[2346022]: Connection closed by authenticating user root 60.213.10.81 port 41644 [preauth]
|
| - |
|
3077 |
Sep 30 05:54:20 silverblue-guest.qbpwcf.org sshd-session[2346860]: Invalid user qy from 60.213.10.81 port 42960
|
| - |
|
3078 |
Sep 30 05:54:21 silverblue-guest.qbpwcf.org sshd-session[2346860]: pam_unix(sshd:auth): check pass; user unknown
|
| - |
|
3079 |
Sep 30 05:54:21 silverblue-guest.qbpwcf.org sshd-session[2346860]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=60.213.10.81
|
| - |
|
3080 |
Sep 30 05:54:22 silverblue-guest.qbpwcf.org sshd-session[2346860]: Failed password for invalid user qy from 60.213.10.81 port 42960 ssh2
|
| - |
|
3081 |
Sep 30 05:54:23 silverblue-guest.qbpwcf.org sshd-session[2346860]: Connection closed by invalid user qy 60.213.10.81 port 42960 [preauth]
|
| - |
|
3082 |
Sep 30 06:08:06 silverblue-guest.qbpwcf.org sshd-session[2378295]: Connection closed by 167.94.145.105 port 55712 [preauth]
|
| - |
|
3083 |
Sep 30 08:09:51 silverblue-guest.qbpwcf.org sshd-session[2662907]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=183.13.207.69 user=root
|
| - |
|
3084 |
Sep 30 08:09:54 silverblue-guest.qbpwcf.org sshd-session[2662907]: Failed password for root from 183.13.207.69 port 18258 ssh2
|
| - |
|
3085 |
Sep 30 08:09:54 silverblue-guest.qbpwcf.org sshd-session[2662907]: Connection closed by authenticating user root 183.13.207.69 port 18258 [preauth]
|
| - |
|
3086 |
Sep 30 08:10:11 silverblue-guest.qbpwcf.org sshd-session[2663658]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=183.13.207.69 user=root
|
| - |
|
3087 |
Sep 30 08:10:13 silverblue-guest.qbpwcf.org sshd-session[2663658]: Failed password for root from 183.13.207.69 port 17293 ssh2
|
| - |
|
3088 |
Sep 30 08:10:13 silverblue-guest.qbpwcf.org sshd-session[2663658]: Connection closed by authenticating user root 183.13.207.69 port 17293 [preauth]
|
| - |
|
3089 |
*/
|
| - |
|
3090 |
|
| - |
|
3091 |
#認證失敗的關鍵字
|
| - |
|
3092 |
$keyWordFP=" Failed password ";
|
| - |
|
3093 |
|
| - |
|
3094 |
#不存在使用者的關鍵字
|
| - |
|
3095 |
$keyWordIU=" Invalid user ";
|
| - |
|
3096 |
|
| - |
|
3097 |
#搜尋符合關鍵字的log行
|
| - |
|
3098 |
#函式說明:
|
| - |
|
3099 |
#檢查多個字串中的每個字串是否有多個關鍵字
|
| - |
|
3100 |
#回傳結果:
|
| - |
|
3101 |
#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
|
| - |
|
3102 |
#$result["function"],當前執行的函數名稱.
|
| - |
|
3103 |
#$result["error"],錯誤訊息.
|
| - |
|
3104 |
#$result["argu"],使用的參數.
|
| - |
|
3105 |
#$result["foundedTrueKey"],結果為"true"的被搜尋元素key陣列,與其數值內容.
|
| - |
|
3106 |
#$result["foundedKeyWords"],找到的關鍵字陣列.
|
| - |
|
3107 |
#$result["foundedFalseKey"],結果為"false"的被搜尋元素key陣列,與其數值內容.
|
| - |
|
3108 |
#$result["foundedTrueKeyWords"],二維陣列,各個字串有找到的關鍵字陣列.
|
| - |
|
3109 |
#$result["foundedAll"],是否每個關鍵字都有找到,"true"代表每個都有找到,"false"代表沒有每個都找到.
|
| - |
|
3110 |
#$result["keyWordsIncludeStr"],陣列,儲存有找到關鍵字的來源的索引(sourceIndex)與其內容(sourceVal)跟找到的關鍵字項目陣列(KeyWords).
|
| - |
|
3111 |
#必填參數:
|
| - |
|
3112 |
#$conf["keyWords"],字串陣列,想要搜尋的關鍵字.
|
| - |
|
3113 |
$conf["search::findManyKeyWordsFromManyString"]["keyWords"]=array($keyWordFP,$keyWordIU);
|
| - |
|
3114 |
#$conf["stringArray"],字串陣列,要被搜尋的字串內容陣列.
|
| - |
|
3115 |
$conf["search::findManyKeyWordsFromManyString"]["stringArray"]=$callShell["output"];
|
| - |
|
3116 |
#可省略參數:
|
| - |
|
3117 |
#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為"false"不需要完全符合.
|
| - |
|
3118 |
#$conf["completeEqual"]="true";
|
| - |
|
3119 |
#參考資料:
|
| - |
|
3120 |
#無.
|
| - |
|
3121 |
#備註:
|
| - |
|
3122 |
#無.
|
| - |
|
3123 |
$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
|
| - |
|
3124 |
unset($conf["search::findManyKeyWordsFromManyString"]);
|
| - |
|
3125 |
|
| - |
|
3126 |
#如果執行失敗
|
| - |
|
3127 |
if($findManyKeyWordsFromManyString["status"]==="false"){
|
| - |
|
3128 |
|
| - |
|
3129 |
#設置執行失敗
|
| - |
|
3130 |
$result["status"]="false";
|
| - |
|
3131 |
|
| - |
|
3132 |
#設置錯誤訊息
|
| - |
|
3133 |
$result["error"]=$findManyKeyWordsFromManyString;
|
| - |
|
3134 |
|
| - |
|
3135 |
#回傳結果
|
| - |
|
3136 |
return $result;
|
| - |
|
3137 |
|
| - |
|
3138 |
}#if end
|
| - |
|
3139 |
|
| - |
|
3140 |
#初始化儲存可能有問題的存取ssh服務遠端ip
|
| - |
|
3141 |
$risky_ips=array();
|
| - |
|
3142 |
|
| - |
|
3143 |
#針對每個符合的log行
|
| - |
|
3144 |
foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $index => $oriLog){
|
| - |
|
3145 |
|
| - |
|
3146 |
#找到的關鍵字
|
| - |
|
3147 |
$foundKeyWord=$findManyKeyWordsFromManyString["foundedTrueKeyWords"][$index][0];
|
| - |
|
3148 |
|
| - |
|
3149 |
#依照符合的關鍵字
|
| - |
|
3150 |
switch($foundKeyWord){
|
| - |
|
3151 |
|
| - |
|
3152 |
#如果是秘密碼錯誤
|
| - |
|
3153 |
case $keyWordFP:
|
| - |
|
3154 |
|
| - |
|
3155 |
#範例
|
| - |
|
3156 |
#Sep 30 08:10:13 silverblue-guest.qbpwcf.org sshd-session[2663658]: Failed password for root from 183.13.207.69 port 17293 ssh2
|
| - |
|
3157 |
#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} Failed password for ${account} from ${ip} ${doNotNeed}
|
| - |
|
3158 |
|
| - |
|
3159 |
#取得時間點跟遠端IP
|
| - |
|
3160 |
#函式說明:
|
| - |
|
3161 |
#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
|
| - |
|
3162 |
#回傳結果:
|
| - |
|
3163 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
3164 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
3165 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
3166 |
#$result["argu"],所使用的參數.
|
| - |
|
3167 |
#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
|
| - |
|
3168 |
#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
|
| - |
|
3169 |
#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
|
| - |
|
3170 |
#必填參數:
|
| - |
|
3171 |
#$conf["input"],字串,要檢查的字串.
|
| - |
|
3172 |
$conf["search::findSpecifyStrFormat"]["input"]=$oriLog;
|
| - |
|
3173 |
#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
|
| - |
|
3174 |
$conf["search::findSpecifyStrFormat"]["format"]="\${month} \${day} \${hour}:\${min}:\${sec} \${doNotNeed} Failed password for \${account} from \${ip} \${doNotNeed}";
|
| - |
|
3175 |
#可省略參數:
|
| - |
|
3176 |
#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
|
| - |
|
3177 |
#$conf["search::findSpecifyStrFormat"]["varEqual"]=array(null,"found");
|
| - |
|
3178 |
#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
|
| - |
|
3179 |
#$conf["varCon"]=array("no_tail"=>" not");
|
| - |
|
3180 |
#參考資料:
|
| - |
|
3181 |
#無.
|
| - |
|
3182 |
#備註:
|
| - |
|
3183 |
#無.
|
| - |
|
3184 |
$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
|
| - |
|
3185 |
unset($conf["search::findSpecifyStrFormat"]);
|
| - |
|
3186 |
|
| - |
|
3187 |
#如果分割失敗
|
| - |
|
3188 |
if($findSpecifyStrFormat["status"]==="false"){
|
| - |
|
3189 |
|
| - |
|
3190 |
#設置執行失敗
|
| - |
|
3191 |
$result["status"]="false";
|
| - |
|
3192 |
|
| - |
|
3193 |
#設置錯誤訊息
|
| - |
|
3194 |
$result["error"]=$findSpecifyStrFormat;
|
| - |
|
3195 |
|
| - |
|
3196 |
#回傳結果
|
| - |
|
3197 |
return $result;
|
| - |
|
3198 |
|
| - |
|
3199 |
}#if end
|
| - |
|
3200 |
|
| - |
|
3201 |
#如果沒有符合格式
|
| - |
|
3202 |
if($findSpecifyStrFormat["found"]==="false"){
|
| - |
|
3203 |
|
| - |
|
3204 |
#跳過該行
|
| - |
|
3205 |
continue 2;
|
| - |
|
3206 |
|
| - |
|
3207 |
}#if end
|
| - |
|
3208 |
|
| - |
|
3209 |
#取得時間點
|
| - |
|
3210 |
$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
|
| - |
|
3211 |
|
| - |
|
3212 |
#取得ip
|
| - |
|
3213 |
$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
|
| - |
|
3214 |
|
| - |
|
3215 |
#儲存其資訊
|
| - |
|
3216 |
$risky_ips[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
|
| - |
|
3217 |
|
| - |
|
3218 |
#跳出 switch
|
| - |
|
3219 |
break;
|
| - |
|
3220 |
|
| - |
|
3221 |
#如果是不存在的使用者
|
| - |
|
3222 |
case $keyWordIU:
|
| - |
|
3223 |
|
| - |
|
3224 |
#範例
|
| - |
|
3225 |
#Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: Invalid user lizepeng from 60.213.10.69 port 39156
|
| - |
|
3226 |
#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} Invalid user ${account} from ${ip} port ${doNotNeed}
|
| - |
|
3227 |
|
| - |
|
3228 |
#取得時間點跟遠端IP
|
| - |
|
3229 |
#函式說明:
|
| - |
|
3230 |
#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
|
| - |
|
3231 |
#回傳結果:
|
| - |
|
3232 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
3233 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
3234 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
3235 |
#$result["argu"],所使用的參數.
|
| - |
|
3236 |
#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
|
| - |
|
3237 |
#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
|
| - |
|
3238 |
#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
|
| - |
|
3239 |
#必填參數:
|
| - |
|
3240 |
#$conf["input"],字串,要檢查的字串.
|
| - |
|
3241 |
$conf["search::findSpecifyStrFormat"]["input"]=$oriLog;
|
| - |
|
3242 |
#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
|
| - |
|
3243 |
$conf["search::findSpecifyStrFormat"]["format"]="\${month} \${day} \${hour}:\${min}:\${sec} \${doNotNeed} Invalid user \${account} from \${ip} port \${doNotNeed}";
|
| - |
|
3244 |
#可省略參數:
|
| - |
|
3245 |
#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
|
| - |
|
3246 |
#$conf["search::findSpecifyStrFormat"]["varEqual"]=array(null,"found");
|
| - |
|
3247 |
#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
|
| - |
|
3248 |
#$conf["varCon"]=array("no_tail"=>" not");
|
| - |
|
3249 |
#參考資料:
|
| - |
|
3250 |
#無.
|
| - |
|
3251 |
#備註:
|
| - |
|
3252 |
#無.
|
| - |
|
3253 |
$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
|
| - |
|
3254 |
unset($conf["search::findSpecifyStrFormat"]);
|
| - |
|
3255 |
|
| - |
|
3256 |
#如果分割失敗
|
| - |
|
3257 |
if($findSpecifyStrFormat["status"]==="false"){
|
| - |
|
3258 |
|
| - |
|
3259 |
#設置執行失敗
|
| - |
|
3260 |
$result["status"]="false";
|
| - |
|
3261 |
|
| - |
|
3262 |
#設置錯誤訊息
|
| - |
|
3263 |
$result["error"]=$findSpecifyStrFormat;
|
| - |
|
3264 |
|
| - |
|
3265 |
#回傳結果
|
| - |
|
3266 |
return $result;
|
| - |
|
3267 |
|
| - |
|
3268 |
}#if end
|
| - |
|
3269 |
|
| - |
|
3270 |
#如果沒有符合格式
|
| - |
|
3271 |
if($findSpecifyStrFormat["found"]==="false"){
|
| - |
|
3272 |
|
| - |
|
3273 |
#跳過該行
|
| - |
|
3274 |
continue 2;
|
| - |
|
3275 |
|
| - |
|
3276 |
}#if end
|
| - |
|
3277 |
|
| - |
|
3278 |
#取得時間點
|
| - |
|
3279 |
$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
|
| - |
|
3280 |
|
| - |
|
3281 |
#取得ip
|
| - |
|
3282 |
$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
|
| - |
|
3283 |
|
| - |
|
3284 |
#儲存其資訊
|
| - |
|
3285 |
$risky_ips[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
|
| - |
|
3286 |
|
| - |
|
3287 |
#跳出 switch
|
| - |
|
3288 |
break;
|
| - |
|
3289 |
|
| - |
|
3290 |
#不應該執行到這邊
|
| - |
|
3291 |
default:
|
| - |
|
3292 |
|
| - |
|
3293 |
#設置執行失敗
|
| - |
|
3294 |
$result["status"]="false";
|
| - |
|
3295 |
|
| - |
|
3296 |
#設置錯誤訊息
|
| - |
|
3297 |
$result["error"][]="unexpected error";
|
| - |
|
3298 |
|
| - |
|
3299 |
#設置錯誤訊息
|
| - |
|
3300 |
$result["error"][]=$findManyKeyWordsFromManyString;
|
| - |
|
3301 |
|
| - |
|
3302 |
#回傳結果
|
| - |
|
3303 |
return $result;
|
| - |
|
3304 |
|
| - |
|
3305 |
}#switch end
|
| - |
|
3306 |
|
| - |
|
3307 |
}#foreach end
|
| - |
|
3308 |
|
| - |
|
3309 |
#針對每個可能有問題ip的每個log行
|
| - |
|
3310 |
foreach($risky_ips as $ip => $infos){
|
| - |
|
3311 |
|
| - |
|
3312 |
#初始化暫存歷史記錄的陣列
|
| - |
|
3313 |
$history=array();
|
| - |
|
3314 |
|
| - |
|
3315 |
#初始化記錄ip來訪不大於1分鐘的計數
|
| - |
|
3316 |
$count=0;
|
| - |
|
3317 |
|
| - |
|
3318 |
#針對每個log行資訊
|
| - |
|
3319 |
foreach($infos as $index => $info){
|
| - |
|
3320 |
|
| - |
|
3321 |
#unixtime
|
| - |
|
3322 |
$time=strtotime($info["time"]);
|
| - |
|
3323 |
|
| - |
|
3324 |
#如果沒有下筆記錄
|
| - |
|
3325 |
if(!isset($infos[$index+1])){
|
| - |
|
3326 |
|
| - |
|
3327 |
#結束 foreach
|
| - |
|
3328 |
break;
|
| - |
|
3329 |
|
| - |
|
3330 |
}#if end
|
| - |
|
3331 |
|
| - |
|
3332 |
#取得unixtime
|
| - |
|
3333 |
$next_time=strtotime($infos[$index+1]["time"]);
|
| - |
|
3334 |
|
| - |
|
3335 |
#如果下筆時間記錄與當前這筆間隔大於60秒
|
| - |
|
3336 |
if($next_time-$time>60){
|
| - |
|
3337 |
|
| - |
|
3338 |
#跳過,看下筆記錄
|
| - |
|
3339 |
continue;
|
| - |
|
3340 |
|
| - |
|
3341 |
}#if end
|
| - |
|
3342 |
|
| - |
|
3343 |
#計數+1
|
| - |
|
3344 |
$count++;
|
| - |
|
3345 |
|
| - |
|
3346 |
#記錄該次記錄
|
| - |
|
3347 |
$history[]=array("time"=>$time,"log"=>$info["log"]);
|
| - |
|
3348 |
|
| - |
|
3349 |
}#foreach end
|
| - |
|
3350 |
|
| - |
|
3351 |
#如果有達到3次
|
| - |
|
3352 |
if($count>=3){
|
| - |
|
3353 |
|
| - |
|
3354 |
#初始化暫存的陣列
|
| - |
|
3355 |
$tmp=array();
|
| - |
|
3356 |
|
| - |
|
3357 |
#取得資訊
|
| - |
|
3358 |
$tmp["info"]=$history;
|
| - |
|
3359 |
|
| - |
|
3360 |
#取得問題ip
|
| - |
|
3361 |
$tmp["ip"]=$ip;
|
| - |
|
3362 |
|
| - |
|
3363 |
#記錄攻擊者的IP
|
| - |
|
3364 |
$attacker_ips_ssh[]=$tmp;
|
| - |
|
3365 |
|
| - |
|
3366 |
}#if end
|
| - |
|
3367 |
|
| - |
|
3368 |
}#foreach end
|
| - |
|
3369 |
|
| - |
|
3370 |
#設置結果
|
| - |
|
3371 |
$result["content"]=$attacker_ips_ssh;
|
| - |
|
3372 |
|
| - |
|
3373 |
#設置執行正常
|
| - |
|
3374 |
$result["status"]="true";
|
| - |
|
3375 |
|
| - |
|
3376 |
#回傳結果
|
| - |
|
3377 |
return $result;
|
| - |
|
3378 |
|
| - |
|
3379 |
}#function checkSshAttackLog end
|
| 1288 |
|
3380 |
|
| 1289 |
}#class security end
|
3381 |
}#class security end
|
| 1290 |
|
3382 |
|
| 1291 |
?>
|
3383 |
?>
|