版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
手把你必赢客系列之江苏快【破文标题】手把你必赢客系列之江苏快3-源码逆向、HTTP劫持、算法加、架设【工具】dotPeek32v1.3;Fiddler;FiddlerCore;VS2013【平台】Window【软件名称】必赢客系列之江苏快【原版大家好,距离上一期手把手系列文章已经一年有余了,惭愧惭愧新年之际,迟来的文章献给为PYG坛友,祝大家猴年快乐。安装原版程序后,用一个免费的帐号,用户名:111111,:111111,登陆软件后,尝试使用某些能时候提示如下图中所述,“你没有使用此功能的权限”,而且用户权限为预览版,数据不能自动更新。12,必须输入用户名和,而且是服务器端验证3,HTTP传输,数据被加理,而且验证Session为了进一步弄明白此款软件的网络验证,打开Fiddler前3GET<ResponseResult="1"Remark="预登陆成功"ServiceState="-<DataSessionID="c471e597-b77d-484b-a39a-95f023df584f"SessionCode="c80cf28d-755f-45eb-b4bf-c6078f7bcce0"/>GET/?Action=Login&Service=26&SessionID=c471e597-<ResponseResult="1"Remark<UserInfoUserName="111111"RegisterTime="2012-09-2219:45:55"QQ=""=""=""AppServer=""LatestLoginIP=""LatestLoginTime=""ServiceExpiration=""/></Data><Mes第一条:id和Service是向服务器发送的软件版本相关数据,返回当前可用的url及IP第二条:actionPreLogin6SessionIDSessionCode,SeriveState据,具体的含义及内部目前不知。第三条:acton参数:Logn,后面跟随着SessonD,返回数据提示登录成功,并提供了用户111111的相关信息,根据字面意,包括了帐号时间、服务到期时间、末次登录时间、IP等。其中第二条、第三条请求数据中均附加了SafeSign参数,显然是对提交的数据有效性检测。关于SafeSign加密原理,文章后面会详细说明。 <ResponseResult="-2"Remark="错误!"ServiceState="-可见,PreLogin数据提交后返回了错误,进而终止了Login数据进一步提交二、简单技Fiddler提供了AutoResponder功能模块,可以本地劫持HTTP数据包,并可对其内容进行修改,返回包含了自定义数据的包。正如图中所述,IfrequestmatchesthenrespondwithFiddlerRespond数据包),注意请勾选"Unmatchedrequestspassthrough"(放行未匹配请求)Surprse!软件顺利打开了主界面,是不是很惊喜~但是很快,一个错误提示框映入眼帘。之所以提示错误框,是因为一条这样的Request数据包被发送到服务器,并返回了如下数据 GET/?Action=clock2&Service=26&SessionID=c471e597-b77d-484b-a39a- <ResponseResult="-3Remark="您的登录凭证已超时失效,请重新登录。"/>我们先暂时关闭Fiddler的AutoResponder功能,再次用账户111111,111111登录一下,尝试抓取正常 GET/?Action=clock2&Service=26&SessionID=60f014c5-489f-4c60-af82-<ResponseResult="1"Remark=""好,行动起来,激活Fiddler的AutoResponder很好,再也没有提示错误提示框了。注意程序一直在与服务器交流,从Fiddler数据列表可以发现。<ResponseResult="1"RemarkServiceState="-<ResponseResult="1"RemarkServiceState="-接下面我们来尝试修改此值,依次将ServiceState改成1、2、3、4、5,重新登录看看有什么变化。结果时:1基础版本;2:标准版本;3以上专业版本。接下来,总要把PYG官网打到软件内,修改登录用户名为" 到目前为止,我们通过Fdder劫持HTTP数据,按照规则自定义的服务器返回的数据,成功了软件,可以使用软件几乎全部的功能。但是,发现了一个问题,数据无法自动更新了。就像困在茫茫大海的一座孤岛上,纵有宝藏万千,却无人与外界同步。三、源码逆向、加分那么接下来,我们从出发,分析加密机制,完全仿造真实的HTTP数据,向服务器获取资源看来要逆向软件的源码了。这款软件采用微软C#.Net语言编写,那么使用dotPeek32v1.3逆向源码! privateprivatevoidprivateprivatevoidLogin()privatevoidpleted(objectpletedEventArgspleted(objectpletedEventArgs分别对应着Request、Response现在我们重点目标放在 方面,所以ProLogin、Login这两个函数非常关键privateprivatevoid{this._currentFormInfo.UserName=this.NameField.Text.Trim();this._currentFormInfo.RemeberPassword=this.RemeberPwdField.IsChecked.Value;this._currentFormInfo.AutoLogin=this.AutoLoginField.IsChecked.Value;ifthis._sha256Pwd=Cryptography.EncryptSHA256(this.PasswordField.Text); =newWeb EncodingserviceEncoding=CoreApp.Current.ServiceEncoding; .Encoding=serviceEncoding;pletedEventHandlercompletedEventHandler=new pleted+=CoreApp.Current.ActualServiceUrl=this._tryTimes>0?CoreApp.Current.ServiceUrl:CoreApp.Current.ServiceIP;string[]strArray=newstring[10];intindex1=stringactualServiceUrl=CoreApp.Current.ActualServiceUrl;strArray[index1]=actualServiceUrl;intindex2=stringstr1="?Action=PreLogin6&Service=";strArray[index2]=str1;intindex3=stringserviceId=CoreApp.Current.ServiceID;strArray[index3]=serviceId;intindex4=stringstr2="&UserName=";strArray[index4]=str2;intintindex5=stringuserName=this._currentFormInfo.UserName;strArray[index5]=userName;intindex6=stringstr3="&Ver=";strArray[index6]=str3;intindex7=6;stringstr4=CoreApp.Current.AppVersion.ToString();strArray[index7]=str4;intindex8=stringstr5=string.IsNullOrWhiteSpace(CoreApp.Current.Remarks)?"":"&Remarks="+strArray[index8]=str5;intindex9=8;stringstr6="&SafeSign=";strArray[index9]=str6;intindex10=stringstr7=Cryptography.EncryptSHA256(CoreApp.Current.ServiceID+this._currentFormInfo.UserName+strArray[index10]=Uriaddress=newUri(string.Concat(strArray),UriKind.Absolute); }private{(senderprivate{(senderaspleted(objectpletedEventArgs)pleted-= stringserviceIp=CoreApp.Current.ServiceIP;stringserviceUrl=CoreApp.Current.ServiceUrl;this._currentFormInfo.SessionID=xelement.Element((XName)"Data").Attribute((XName)this._currentFormInfo.SessionCode=Cryptography.EncryptSHA256(xelement.Element((XName)"Data").Attribute((XName)"SessionCode").Value+this._sha256Pwd);}this._sha256Pwdthis._sha256Pwd= Loginprivateprivatevoid{ =newEncodingserviceEncoding=CoreApp.Current.ServiceEncoding; .Encoding=serviceEncoding;pletedEventHandlercompletedEventHandler=new pleted+=completedEventHandler;string[]strArray=newstring[7];intindex1=stringactualServiceUrl=CoreApp.Current.ActualServiceUrl;strArray[index1]=actualServiceUrl;intindex2=stringstr1="?Action=Login&Service=";strArray[index2]=str1;intindex3=stringserviceId=CoreApp.Current.ServiceID;strArray[index3]=serviceId;intindex4=stringstr2="&SessionID=";strArray[index4]=str2;intindex5=stringsessionId=this._currentFormInfo.SessionID;strArray[index5]=sessionId;intindex6=stringstr3="&SafeSign=";strArray[index6]=str3;intindex7=stringstr4=Cryptography.EncryptSHA256(CoreApp.Current.ServiceID+this._currentFormInfo.SessionID+strArray[index7]=Uriaddress=newUri(string.Concat(strArray),UriKind.Absolute); }privateprivate{pleted(objectpletedEventArgsXElementxelement1=if(xelement1.Attribute((XName)"Result").Value!={this._currentFormInfo.SessionID=(string)intnumintRGBMessageBox.Show(xelement1.Attribute((XName)Remark").Value,(Window)null,RGBMesType.None,RGBMesButtons.Ok);}{XElementxelement2=xelement1.Element((XName)"Data").Element((XName)"UserInfo");UserExtendInfouserExtendInfo=newUserExtendInfo();=userExtendInfo.UserName=xelement2.Attribute((XName)"UserName").Value;userExtendInfo.RegisterTime=Convert.ToDateTime(xelement2.Attribute((XName)"RegisterTime").Value);userExtendInfo.QQ=xelement2.Attribute((XName)"QQ").Value;= xelement2.Attribute((XName) =xelement2.Attribute((XName)" userExtendInfo.LatestLoginAppServer=xelement2.Attribute((XName)"AppServer").Value;userExtendInfo.LatestLoginIP=xelement2.Attribute((XName)"LatestLoginIP").Value;if(!string.IsNullOrWhiteSpace(xelement2.Attribute((XName)"LatestLoginTime").Value))userExtendInfo.LatestLoginTime=newDateTime?(Convert.ToDateTime(xelement2.Attribute((XName)if(!string.IsNullOrWhiteSpace(xelement2.Attribute((XName)"ServiceExpiration").Value))userExtendInfo.ServiceExpiration=newDateTime?(Convert.ToDateTime(xelement2.Attribute((XName) .UserInfo= .TermInfo=xelement1.Element((XName)"Data").Element((XName)"TermInfo");XElementxelement3=xelement1.Element((XName)"Data").Element((XName)"TermSubUserCount");if(xelement3!=null) .TermSubUserCount=Convert.ToInt32(xelement3.Value); .SessionID=this._currentFormInfo.SessionID; .SessionCode=this._currentFormInfo.SessionCode;if(xelement1.Attribute((XName)"ShareUrl")!=null)this._lottery.SetShareUrlBase(xelement1.Attribute((XName)"ShareUrl").Value); ) }}通过简单分析以上4个方法的实现细节,梳理清楚其中加密方法不是很,所以可以很容易生成真实SafeSign四、高级技术-代码下面正式请出本文的人物 FiddlerCoreisa.NETClasslibraryyoucanintegrateintoyour.NETFrameworkandMonoFrameworkapplications.FiddlerCoreallowsyoutocaptureandmodifyHTTPandHTTPStrafficjustlikeFiddler,withoutanyoftheFiddlerUI.大家可以到官网进一步了解FiddlerCore开始我们代码,新建一个C#窗体应用程序项目publicpublicclass{publicstaticstringurlPreLogin="?Action=PreLogin";publicstaticstringurlLogin="?Action=Login";publicstaticstringurlClock="?Action=clock";publicstaticstringsessionID;publicstaticstringsessionCode;publicpublicstaticstringserviceId;publicstaticstringver;publicstaticstringuserName="111111";publicstaticstringuserPassword="111111";}privatevoidFiddlerApplication_BeforeRequest(SessionoS)privatevoidprivatevoidFiddlerApplication_BeforeRequest(SessionoS)privatevoidFiddlerApplication_BeforeResponse(SessionoS)根据方法名的字面意思,一个是在Request请求之前Hook,一个是在Respone回应之前Hook接下来要做的事情是:预登录获取Sesson,保持连接有效性下,确保正确重签名(SafeSign)后与服务器交流数据。privatevoidFiddlerApplication_BeforeRequest(SessionprivatevoidFiddlerApplication_BeforeRequest(SessionoS.bBufferResponse=//ProLogin->getserviceId,ver->setnew//hookusername&if{ShowDbgMsg("1.orgURL_prelogin:"+oS.fullUrl);stringurl_preLogin=oS.fullUrl;73C819911B2C7F1E3A19C1C5FFD5A99724FA1FA3346A5HTTP/1.1string[]pars=url_preLogin.Split('&');foreach(stringpinpars){if(p.ToLower().StartsWith("service="))BYKJSK3.serviceId=p.Substring("service=".Length);elseif(p.ToLower().StartsWith("ver="))BYKJSK3.ver=p.Substring("ver=".Length);}url_preLogin=+"&Service="++"&UserName="++"&Ver="++"&SafeSign="+BYKJSK3.serviceId+BYKJSK3.userName+//urloS.fullUrl=ShowDbgMsg("1.newURL_prelogin:"+}privatevoidFiddlerApplication_BeforeResponse(privatevoidFiddlerApplication_BeforeResponse(Sessionif{ShowDbgMsg("2.orgPrlLoginRespone:"+oS.GetResponseBodyAsString());XElementxelement=XElement.Parse(oS.GetResponseBodyAsString());BYKJSK3.sessionID=xelement.Element((XName)"Data").Attribute((XName)"SessionID").Value;BYKJSK3.sessionCode=Cryptography.EncryptSHA256(xelement.Element((XName)"Data").Attribute((XName)"SessionCode").Value+//ResponseBodychanged!//ResponseBodychanged!ShowDbgMsg("2.newProLoginRespone:"+xelement.ToString());}privatevoidFiddlerApplication_BeforeRequest(SessionprivatevoidFiddlerApplication_BeforeRequest(Sessionif{ShowDbgMsg("3.orgURL_login:"+oS.fullUrl);stringurl_Login=oS.fullUrl;string[]pars=url_Login.Split('&');url_Login=+"&Service="++"&SessionID="++"&SafeSign="Cryptography.EncryptSHA256(BYKJSK3.serviceId+BYKJSK3.sessionID+BYKJSK3.sessionCode);//urlchanged!oS.fullUrl=url_Login;ShowDbgMsg("3.newURL_login:"+}privatevoidFiddlerApplication_BeforeResponse(SessionifprivatevoidFiddlerApplication_BeforeResponse(Sessionif{ShowDbgMsg("4.orgLoginRespone:"+oS.GetResponseBodyAsString());XElementxelement=XElement.Parse(oS.GetResponseBodyAsString());XElementxelement2=xelement.Element((XName)"Data").Element((XName)"UserInfo"); //ResponseBodychanged!ShowDbgMsg("4.newLoginResponse:"+xelement.ToString());ShowMsg2("Info:loginsuccess!goodluckforyou!");}privatevoidFiddlerApplication_BeforeRequest(Sessionif{ShowDbgMsg("5.orgURL_clock:"privatevoidFiddlerApplication_BeforeRequest(Sessionif{ShowDbgMsg("5.orgURL_clock:"+oS.fullUrl);stringurl_Clock=oS.fullUrl;//GET/?Action=clock2&Service=26&SessionID=84304c37-ee97-431b-b2b6- //&randmoncode=27a39640-2782-48cf-9d20- stringurl_1=url_Clock.Substring(0,url_Clock.ToLower().IndexOf("&sign="));stringurl_2=url_1.Split('?')[1];url_Clock=url_1+"&Sign="+Cryptography.EncryptSHA256(url_2+oS.fullUrl=ShowDbgMsg("5.newURL_clock:"+}6:(Result=privateprivatevoidFiddlerApplication_BeforeResponse(Sessionif{ShowDbgMsg("6.orgClockResponse:"+oS.GetResponseBodyAsString());XElementxelement=XElement.Parse(oS.GetResponseBodyAsString());if(xelement.Attribute((XName)"Result").Value!="1")ShowDbgMsg("6.newClockResponse:"+xelement.ToString());}运行项目,输入用户名111111,111111,查看调试信息6.orgClockResponse:<ResponseResult="-3"6.orgClockResponse:<ResponseResult="-3" 使用盗版软件!"/>6.newClockResponse:<ResponseResult="1" 使用盗版软件!"/>悲伤!有人会问,既然Request这个问题同样也困扰了我,终于在多次分析数据包后发现问题关键:预览版是不会向服务器提交Auto_Data_Update=1这条参数的,服务器在初次PreLogn的时候已经验证了用户名和以及用户所用的版本,并返回了ServceState=-6,而此时却向服务器端越权试图获取升级数据,所以就提示错误!此时,似乎有无数张诡异的讥笑的脸庞,在我脑海中萦绕~,似乎在嘲笑着:让你费尽千辛万苦后仍然失败告终!五、本地数据“服务器一下,尝试找几个可用的API。发现一个可用的,如图:functionasyncDateQuery(dateVal)$.getJSON('jsk3kjjg.php',functionasyncDateQuery(dateVal)$.getJSON('jsk3kjjg.php',{action:'query',date:dateVal,random:Math.random(),id:801,async:true},function(response){..............functionasyncDayQuery(day)$.getJSON('jsk3kjjg.php',{action:'chart',date:map [day],random:Math.random(),id:801,async:true},function(response){...............抓个包,看看具体url路径, <Response<ResponseResult=""1""<Item<Item<Item<Item<Item""CPData=""3,5,1""Date=""2016-01-0812:10:57""""CPData=""1,1,3""Date=""2016-01-0811:59:57""""CPData=""1,2,6""Date=""2016-01-0811:49:57""""CPData=""1,1,2""Date=""2016-01-0811:39:57""""CPData=""2,2,6""Date=""2016-01-0811:29:10""注意到调用其他API返回的是JSON格式数据,获取我们想要的内容,需要解析JSON数据,还好不是很需要借助工具,NewtonsoftJsondll首先写出被序列化的类:privateprivatevoidgetCPDataByDay(DateTimedate,ref{stringurl_1,url_2,url_3;Uriurl;stringdateyyyyMMdd=date.ToString("yyyyMMdd",//beforeday','yesterday',doublespanDays=(DateTime.Today-date).TotalDays;if(spanDays==0)url_1=elseif(spanDays==1)url_1=@"httelseif(spanDays==2)url_1=@"htturl_1=/jsk3kjjg.php?actio
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026江苏对口招生考试(数学)历年参考题库含答案详解
- 2026机械工程师资格考试(综合素质与技能)历年参考题库含答案详解
- 2026教师职称-江苏-江苏教师职称(基础知识、综合素质、小学美术)历年参考题库含答案详解3套试卷
- 基于Agent的自动化测试框架原理教程课程设计
- PCA降维图像处理应用课程设计
- 苯-甲苯精馏课程设计
- OpenCV人脸检测系统开发实战课程设计
- 泵与风机课程设计目的
- 政企共建联建方案范本
- 机器学习垃圾邮件分类案例课程设计
- 小学语文口语训练案例分析范文
- 龋病的健康宣教
- 人教版二年级全册《体育与健康》全套课件
- (2026秋新版)苏教版五年级数学上册全册教案
- 太阳能转化原理与技术课件-第五章光伏发电器件与系统
- 2025注册核安全工程师真题附答案详解(完整版)
- 2025年全国农产品质量安全检测技能竞赛理论知识考试题库(含答案)
- 全员安全生产责任制各部门及各级人员的安全责任清单(含安全职责、履责要求、履责记录)
- 2026年部编版新教材语文二年级上册教学计划(含进度表)
- GB/T 15790-2026稻瘟病测报调查规范
- TSG 08-2026 特种设备使用管理规则
评论
0/150
提交评论