亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
12下一頁(yè)
最近訪問(wèn)板塊 發(fā)新帖
查看: 8143 | 回復(fù): 11
打印 上一主題 下一主題

一個(gè)輕量型完整性檢測(cè)工具-Triproot [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-05-30 12:35 |只看該作者 |倒序?yàn)g覽
前些天為了測(cè)試個(gè)東西,寫(xiě)的監(jiān)控某個(gè)目錄下文件變化的小程序,稍微修改下就成了類(lèi)似tripwire的工具。
編譯: javac triproot.java
運(yùn)行:java triproot -init [Dir you want init] [Output file name]
         java triproot -check [Dir you want check] [Trip file,that must be init early]

在windows2k、window2003、AS5.1上測(cè)試過(guò),linux下編譯運(yùn)行要改個(gè)字符,注釋里有。



   import java.io.*;
   import java.util.*;
   import java.lang.*;
   import java.text.*;

   public class triproot
   {


  static  ArrayList dirlist = new ArrayList();
  static  HashSet filewriter=new HashSet();
  static long filenum=0;
  static long dirnum=0;

  

public   String   getDateString(long unixtime)    //convert unix time to human time

  {  
Date   date   =   new   Date(unixtime);   
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(date);
return dateString;
  }

   void detectwhatisit(String receivefilename)  //detect receivefilename is a dir or a file,push dir to dirlist,push file to filewriter;

   {
            File dir2 = new File(receivefilename);

            boolean isDir = dir2.isDirectory();
            if (isDir)
            {   
            triproot.dirnum++;
            triproot.dirlist.add(receivefilename);
            }
            else
            {
            triproot.filenum++;
            String lastmodified=getDateString(dir2.lastModified());
            triproot.filewriter.add("Size : "+dir2.length() +"\t Last modify : "+lastmodified + " \t File name :"+dir2.getPath() );

            }//else end


    }//end of detectwhatisit






boolean listfile(String getDir)          //scan getDir

{
   File dir = new File(getDir);
   String[] children = dir.list();
   boolean list_if=false;


    if (children == null)
    {
        // Either dir does not exist or is not a directory

        System.out.println("Directory is null");
    }
    else
    {
        for (int i=0; i<children.length; i++)
        {
            // Get filename of file or directory

            String filename = children[i];
            detectwhatisit(getDir+"\\"+filename);   //if os is linux,replace "\\" to "/"


            if((i+1)==children.length)
            {
                list_if=true;
                }
            else{list_if=false;}                 //if scan getDir is done,set list_if=true


        }//for end

    }//else end

    return list_if;
}//end of listfile



void init_dir(String original,String outDir)
{
ArrayList templist=new ArrayList();
if(new triproot().listfile(original))
{
while(dirlist.size()!=0)
{
for(int j=0;j<dirlist.size();j++)
{
templist.add(dirlist.get(j).toString());
            if((j+1)==dirlist.size())
            dirlist.clear();                   //copy dirlist to templist,and clear dirlist

}

for(int k=0;k<templist.size();k++)                      //scan the second round dir

{
new triproot().listfile(templist.get(k).toString());
        if((k+1)==templist.size()){
             templist.clear(); }
            else{}
}

if(dirlist.size()==0)
{
try
{
  PrintWriter out2 = new PrintWriter(new FileWriter(outDir));
  Iterator ir=filewriter.iterator();
  while(ir.hasNext())
  {
   out2.println(ir.next());
  }

System.out.println("Total dirs is: "+triproot.dirnum);
System.out.println("Total files is: "+triproot.filenum);
out2.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
  }//end of while

  }
}//end of  function init_dir




void check_dir(String newList,String oldList)
{
try
{
BufferedReader new_List =new BufferedReader(new FileReader(newList));
BufferedReader old_List =new BufferedReader(new FileReader(oldList));
HashSet new_hash=new HashSet();
HashSet old_hash=new HashSet();
String s=new String();
   
    while((s = new_List.readLine())!= null)
            {
                new_hash.add(s);   
            }
   
            
            new_List.close();
    while((s = old_List.readLine())!= null)
            {
                old_hash.add(s);   
            }
        
            old_List.close();

  File delete_temp = new File(newList);
  delete_temp.delete();


  Iterator irq=new_hash.iterator();
  int countChange=0;
  System.out.println("-----------Start Check-----------------------------------------------------");
  while(irq.hasNext())
  {
   s =(String)irq.next();
   if(old_hash.contains(s))
   {
   
   }
   else
   {
   System.out.println(s);
   countChange++;
   }
  }
  System.out.println("-----------Check Done!-----------------------------------------------------");
  System.out.println("Total "+countChange+ " Files have been Modified!!!");

}

catch(Exception e)
{
System.out.println(e);
}
}//end of function check_dir



public static void main(String args[])   
{
try{
if(args.length!=3)
{

if(args[0].equals("-help"))
{
System.out.println("User Guide :");
System.out.println("java triproot -init [Dir you want init] [Output file name]");
System.out.println("java triproot -check [Dir you want check] [Trip file,that must be init early]");
System.out.println("IF Dir include space,don't forget \"\" !");
System.exit(1);

}

if(args[0].equals("-check")||args[0].equals("-init"))
{
System.out.println("Incompleted :");
System.out.println("Please type \"java triproot -help\" for more infomation!");
System.exit(1);

}


System.out.println("Unkonw command "+ args[0]);
System.out.println("Please type \"java triproot -help\" for more infomation!");
System.exit(1);
}
}
catch(Exception e)
{
System.out.println(e);
System.out.println("catched input error");
}




if(args[0].equals("-init"))
{
new triproot().init_dir(args[1],args[2]);
System.exit(0);
}



if(args[0].equals("-check"))
{
String temp_out="temp.out";
new triproot().init_dir(args[1],temp_out);
new triproot().check_dir(temp_out,args[2]);
System.exit(0);
}

else
{
System.out.println("Unkonw command "+ args[0]);
System.out.println("Please type \"java triproot -help\" for more infomation!");
System.exit(1);

}

}//end of main

    }//end of class



[ 本帖最后由 t920 于 2008-5-30 12:40 編輯 ]

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2008-06-03 09:14 |只看該作者
嗯,寫(xiě)得不錯(cuò)!

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-06-04 13:10 |只看該作者
C:\Program Files\Java\jdk1.5.0_12\bin>javac triproot.java
注意:triproot.java 使用了未經(jīng)檢查或不安全的操作。
注意:要了解詳細(xì)信息,請(qǐng)使用 -Xlint:unchecked 重新編譯。

平臺(tái)p-sp3

編譯不成功:(

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2008-06-05 15:37 |只看該作者
ddddddddddddddddd

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2008-06-19 18:06 |只看該作者
有點(diǎn)問(wèn)題

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2008-06-23 01:18 |只看該作者
支持了 強(qiáng)

論壇徽章:
0
7 [報(bào)告]
發(fā)表于 2008-08-22 12:08 |只看該作者
怎么使用的啊?

論壇徽章:
20
CU大;照
日期:2013-04-17 11:48:26羊年新春福章
日期:2015-03-10 22:39:202015年中國(guó)系統(tǒng)架構(gòu)師大會(huì)
日期:2015-06-29 16:11:282015亞冠之平陽(yáng)省
日期:2015-07-31 09:19:042015七夕節(jié)徽章
日期:2015-08-21 11:06:17IT運(yùn)維版塊每日發(fā)帖之星
日期:2015-09-30 06:20:002015亞冠之柏太陽(yáng)神
日期:2015-10-19 20:29:5915-16賽季CBA聯(lián)賽之天津
日期:2016-11-29 14:03:4315-16賽季CBA聯(lián)賽之北控
日期:2016-12-24 20:51:492015年辭舊歲徽章
日期:2015-03-03 16:54:15雙魚(yú)座
日期:2015-01-12 20:58:532014年中國(guó)系統(tǒng)架構(gòu)師大會(huì)
日期:2014-10-14 15:59:00
8 [報(bào)告]
發(fā)表于 2008-12-02 03:16 |只看該作者
嗯,寫(xiě)得不錯(cuò)!

論壇徽章:
0
9 [報(bào)告]
發(fā)表于 2010-05-16 00:53 |只看該作者
頂!

論壇徽章:
0
10 [報(bào)告]
發(fā)表于 2010-05-16 12:11 |只看該作者
路過(guò).支持一下.
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專(zhuān)區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP