得把这些凌乱记录下来,以免再次需要时找得头破血流。。。
虽然有点忙羊补牢的味道,但总比被入侵后无计可施,无处可跟踪好。。
通过对IP记录,接合系统登录日志分析,抽取入侵者IP后,就可以更好对IIS日志进行过滤分析了。
1,找一隐秘地方新建一个文件夹(避免灰客们乱窜发现日志),比如C:\windows\b_log(文件夹新建),在文件夹下新建一批处理文件3389log.bat,内容如下:
- @echo off
- date /t >>C:\WINDOWS\b_log\3389log.log
- time /t >>C:\WINDOWS\b_log\3389log.log
- netstat -an | find ":3389" | find "ESTABLISHED" >> C:\WINDOWS\b_log\3389log.log
2,开始--》运行-->命令gpedit.msc进入策略管理编辑器
3,用户配置--》Windows配置--》脚本--》属性登录--》添加
4,在脚本名上填入新建的批处理3389log.bat文件就可以了。
OK,当启动时候,无知觉中登录者IP和时间就被记录下了。。。
附带一个IIS日志过滤类:
- public class IISLog {
-
- public static void main(String[] args) {
- String log_content = readFileByString("E:\\IISLOG\\ex100429.log", "222.73.173.11", ".jpg,.gif,.png");
- //FileOperate.writeToFile(log_content, "E:\\IISLOG\\29_001.txt"); 输出文件,
- System.out.println(log_content );
- System.out.println("completed");
- }
-
- /**
- * 以行为单位进行内容提取
- * contain 包含字符则提取
- * uncontain 包含字符则排除 优先于contain
- */
- public static String readFileByString(String path, String contain, String uncontain) {
- StringBuffer buffer;
- try {
- File file = new File(path);
- BufferedReader br = new BufferedReader(new FileReader(file));
- buffer = new StringBuffer();
- String line = br.readLine();
- while (line != null) {
- boolean invalid = false;
- boolean availability = false;
- for(String u : uncontain.split(",")) {
- if (line.indexOf(u) > -1) {
- invalid = true;
- break;
- }
- }
- if (!invalid)
- for(String c : contain.split(",")) {
- if (line.indexOf(c) > -1) {
- availability = true;
- break;
- }
- }
- if (availability) {
- buffer.append(line);
- buffer.append("\n");
- }
- line = br.readLine();
- }
- br.close();
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
-
- return buffer.toString();
- }
- }
|