计算机应用 | 古代文学 | 市场营销 | 生命科学 | 交通物流 | 财务管理 | 历史学 | 毕业 | 哲学 | 政治 | 财税 | 经济 | 金融 | 审计 | 法学 | 护理学 | 国际经济与贸易
计算机软件 | 新闻传播 | 电子商务 | 土木工程 | 临床医学 | 旅游管理 | 建筑学 | 文学 | 化学 | 数学 | 物理 | 地理 | 理工 | 生命 | 文化 | 企业管理 | 电子信息工程
计算机网络 | 语言文学 | 信息安全 | 工程力学 | 工商管理 | 经济管理 | 计算机 | 机电 | 材料 | 医学 | 药学 | 会计 | 硕士 | 法律 | MBA
现当代文学 | 英美文学 | 通讯工程 | 网络工程 | 行政管理 | 公共管理 | 自动化 | 艺术 | 音乐 | 舞蹈 | 美术 | 本科 | 教育 | 英语 |

免费基于Aglet的入侵检测系统的实现(一)毕(6)

2013-06-28 01:00
导读:ception exc){ //当没有驱动程序时,应用程序无法继续运行,故退出程序 System.out.println("没有发现驱动程序:"+Driver); exc.printStackTrace();System.exit(1); } try{ //建立与
ception exc){
//当没有驱动程序时,应用程序无法继续运行,故退出程序
System.out.println("没有发现驱动程序:"+Driver);
exc.printStackTrace();System.exit(1);
}
try{
//建立与指定数据库的连接
Connection Connection=DriverManager.getConnection(source);
SQLWarning warn = Connection.getWarnings();
while(warn!=null){
System.out.println(warn.getMessage());
warn=warn.getNextWarning();
}
//创建一个用于执行预编译SQL的语句对象:查询记录的cid
String sql="select ip=dbo.inet_ntoa(ip_src) from iphdr,event,signature where iphdr.cid=event.cid and signature=signature.sig_id and sig_name='SCAN Proxy (8080) attempt'";
PreparedStatement pStm=Connection.prepareStatement(sql);
//发送和执行预编译的SQL语句,获得查询结果集
ResultSet result=pStm.executeQuery();
//"i"用于记录读出数据库多少个记录,"j"在输出记录时用于循环
int i=0,j=0;
//使用迭代模式访问查询结果集,计算有多少条数据
while(result.next()){
i++;                        
}
//关闭查询结果集合
result.close();
//关闭SQL语句
pStm.close();
System.out.println("i="+i);
i=i-1;
//建立"i"个单元的数组
ip=new String[i+1];
//再读数据库
//创建执行简单SQL语句的SQL语句对象
Statement stm=Connection.createStatement(); 
//查询记录的IP地址,发送和执行简单SQL语句,获得查询结果集
sql="select ip=dbo.inet_ntoa(ip_src) from iphdr,event,signature where iphdr.cid=event.cid and signature=signature.sig_id and sig_name='SCAN Proxy (8080) attempt'";
result=stm.executeQuery(sql);
//使用迭代模式访问查询结果集,把数据用数组接受下来 (转载自http://zw.nseac.coM科教作文网)
while(result.next()){
ip[j]=result.getString("ip");
j++;                         
}
//输出数组
for(j=0;j<=i;j++){
int k=j+1;
System.out.println("第"+k+"个IP地址:"+ip[j]+"\t");
}
//关闭查询结果集合
result.close();
//关闭SQL语句
stm.close();
//关闭数据库连接
Connection.close();
}catch(SQLException exc){
System.out.println("在执行数据库访问时发生了错误!");
exc.printStackTrace();
}
}
//建立单项链表,添加头和尾,并把第一个ip地址插入进去。
private void addhead()
{
temp=new node();
head=temp;
temp=new node();
temp.IpSo="end";
end=temp;
head.next=end;
temp=new node();
temp.IpSo=ip[0];
temp.Times=1;
temp.next=head.next;
head.next=temp;
}
//在链表尾添加节点,并把数据写道刚建立的节点中
private void addnode()
{
int i;
if(_theRemote==0)i=1;
else i=0;
while(i<ip.length)
{
search=head.next;
boolean t=false;
temp=new node();
pre=temp;
while(!t&&(search.next!=null))
{
if(ip[i].equals(search.IpSo))
{
t=true;
break;
}
pre.next=search;
search=search.next;
}
if(t){
search.Times=search.Times+1;
}
else
{
search=pre.next;
temp=new node();
temp.IpSo=ip[i];
temp.Times=1;
temp.next=search.next;
search.next=temp;
}
i++;
}
}
 //遍历链表,把链表的节点值输出
private void print()
{
search=head.next;
while(search!=null)
{
if(search.Times>10)
{
System.out.println(search.IpSo+":"+search.Times+"次"); 中国大学排名
}
search=search.next;
}  
}
//数据分析处理
private void addrule()
{
String IP="可疑地址:";
System.out.println("检查分析数据中(是否有攻击数据)………………");
search=head.next;
JFrame frame=new JFrame("基于AGLET平台的分布式入侵检测系统");
frame.setLocation(new Point(341,256));
上一篇:免费个人入侵检测系统的实现(一)毕业论 下一篇:没有了