Skip to content

Instantly share code, notes, and snippets.

@mike-zhang
mike-zhang / nmapScanUdp.py
Created November 16, 2012 05:23
udp端口扫描(python-nmap代码)
#! /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 November 15, 2012 15:43
检测动态域名并上报IP
#!/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 November 12, 2012 05:38
获取网卡IP地址列表(Linux下python实现)
#! /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 November 11, 2012 23:24
流迭代器和算法一起使用
#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 November 9, 2012 08:49
定时显示与特定主机的连接
#! /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 November 8, 2012 06:34
抓取linux桌面视频
#! /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 November 5, 2012 15:21
STL map test : word count
#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 October 29, 2012 15:31
rtsp TCP Client for DarwinStreamingServer(python)
#! /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 October 25, 2012 15:33
交换两个指针(c++)
#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 October 24, 2012 15:13
使用预处理进行调试(c++ demo)
#include <iostream>
//#define NDEBUG // or : g++ -DNDEBUG debugTest.cpp -o debugTest
#include <cassert>
using namespace std;
int main()
{
cout<<__FILE__<<endl;
cout<<__LINE__<<endl;