Skip to content

Instantly share code, notes, and snippets.

@mike-zhang
mike-zhang / nmapScanUdp.py
Created Nov 16, 2012
udp端口扫描(python-nmap代码)
View nmapScanUdp.py
#! /usr/bin/python
import nmap
# python-nmap url : http://xael.org/norman/python/python-nmap/python-nmap-0.1.4.tar.gz
nm = nmap.PortScanner()
nm.scan(hosts='192.168.1.0/24', arguments='-n -p 161 -sU ')
hosts_list = [(x, nm[x][u'udp'][161]['state']) for x in nm.all_hosts()]
#print nm.all_hosts()
#print nm[u'192.168.1.100'][u'udp'][161]['state']
@mike-zhang
mike-zhang / reportMyIp.py
Created Nov 15, 2012
检测动态域名并上报IP
View reportMyIp.py
#!/usr/bin/python
import smtplib,re,urllib2,time
import socket
from subprocess import Popen, PIPE
smtpServer='smtp.163.com'
smtpPort='25'
sender = 'XXXXX@163.com'
senderPasswd = "XXXXX"
@mike-zhang
mike-zhang / getIpList.py
Created Nov 12, 2012
获取网卡IP地址列表(Linux下python实现)
View getIpList.py
#! /usr/bin/python
'''
CentOS 6.2 + Python 2.6
'''
def getIpList():
import os
ipList = []
var = os.popen('ifconfig').read().split("\n\n")
for item in var:
@mike-zhang
mike-zhang / streamIteratorTest.cpp
Created Nov 11, 2012
流迭代器和算法一起使用
View streamIteratorTest.cpp
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
istream_iterator<int> cin_it(cin);
@mike-zhang
mike-zhang / netstatWatch.sh
Created Nov 9, 2012
定时显示与特定主机的连接
View netstatWatch.sh
#! /bin/bash
r_host='10.11.1.100'
if [ -f '/usr/bin/watch' ]
then
watch -n 1 -d "netstat -an | grep $r_host"
else
while [ 1 ]
do
@mike-zhang
mike-zhang / record1.py
Created Nov 8, 2012
抓取linux桌面视频
View record1.py
#! /bin/bash
t1=`date +%Y%m%d%H%M`
path1="/tmp/out_$t1.mpg"
ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq $path1
@mike-zhang
mike-zhang / wordCount1.cpp
Created Nov 5, 2012
STL map test : word count
View wordCount1.cpp
#include <map>
#include <string>
#include <iostream>
using namespace std;
int main()
{
map<string,int> dict;
string word;
@mike-zhang
mike-zhang / rtspTcpClient_DSS.py
Created Oct 29, 2012
rtsp TCP Client for DarwinStreamingServer(python)
View rtspTcpClient_DSS.py
#! /usr/bin/python
import socket,time,string,random,thread
m_Vars = {
"bufLen" : 1024 * 10,
"defaultServerIp" : "192.168.1.100",
"defaultServerPort" : 554,
"defaultTestUrl" : "rtsp://192.168.1.100/test1.mp4",
"defaultUserAgent" : "LibVLC/2.0.3 (LIVE555 Streaming Media v2011.12.23)"
@mike-zhang
mike-zhang / ptrSwap.cpp
Created Oct 25, 2012
交换两个指针(c++)
View ptrSwap.cpp
#include <iostream>
using namespace std;
//using pointer
void ptrSwap1(int **pa,int **pb)
{
int *ptmp = *pa;
*pa = *pb;
*pb = ptmp;
@mike-zhang
mike-zhang / debugTest.cpp
Created Oct 24, 2012
使用预处理进行调试(c++ demo)
View debugTest.cpp
#include <iostream>
//#define NDEBUG // or : g++ -DNDEBUG debugTest.cpp -o debugTest
#include <cassert>
using namespace std;
int main()
{
cout<<__FILE__<<endl;
cout<<__LINE__<<endl;