找回密码
 立即注册
注册 登录
×
热搜: 活动 交友 discuz
查看: 74|回复: 1

从逆向看代码安全

[复制链接]

1

主题

3

帖子

7

积分

新手上路

Rank: 1

积分
7
发表于 2022-11-26 16:26:50 | 显示全部楼层 |阅读模式
发现一个视频APP,觉得片源不错,想下载下来看看,首先想到的就是用flidder或者anyproxy
这里使用anyproxy,因为可以二次开发。
但是抓取完后,发现数据全是加密的


既然加密,那就没办法,必须去反编译,看看怎么加密
解压APK后,发现居然是360加壳的。先脱壳
网上很多脱壳方法,exposed+fdex2是不错的。解压出来是:



虽然dex都dump出来了,但发现有一个dex没法打开。用010修改一下文件头就可以用了。
使用jd-gui开始分析。接口加密,当然就很容易找到request相关的类




从以上代码发现:
APP随机生成一个aesKey,然后再用RAS加密一次得到key,用aesKey进行AES/CBC/PKCS7Padding加密得到body。
虽然在接口里,能看到加密后的key,但是因为RSA是不对称加密,本地也没有存储私钥,因此本地也就无法解密,无法查看到原始加密字符串是什么。
那就只能通过exposed hook来查看原始内容是什么了。
既然找到了加密方法是cryptoAESKey,cryptoBody。那么可以写方法如下:


然后就可以看到原始值是什么了:
{
"currentPage": 1,
"pageSize": 5,
"data": 1
}
后面,就可以自己构造数据,进行提交获取数据啦。
小结:
从逆向看代码安全
1. APK本身要混淆加壳
2. 接口安全:Rsa+aes,aes的key通过rsa加密传输,只有客户端本身(客户端本身没法解,但知道rsa加密前的值)和服务端可以解出来。
3. 关键加密代码放在so库里。一些关键的库,可以做签名检验。
<hr/>procedure Tchardatafrm.FormResize(Sender: TObject);
begin
    Chart2.Width:=Panel2.Width div 2;
     Chart1.Width:=Chart2.Width;
     Panel3.Height:= Height div 2;
end;

procedure Tchardatafrm.startThread(itype: Integer);
begin
  FTYpe:= itype;
   loadconfig;
  PostThread:=TPostThread.Create(cxSpinEdit1.Value,itype,Handle,cxSpinEdit2.Value,cxSpinEdit3.Value,FCurBankUser);
  {
  if itype = 0 then
     RichEdit1.Text:= '"3,6,9","1,4,7","2,5,8"';
  if itype = 1 then
     RichEdit1.Text:= '"1,5,6","2,3,4","7,8,9"';
  if itype = 2 then
     RichEdit1.Text:= '"1,6,10","2,7,9","3,4,8"';
  if itype = 3 then
     RichEdit1.Text:= '"3,5,7","1,2,6","4,9,10"';
  }

end;

procedure Tchardatafrm.FormShow(Sender: TObject);

begin

   downIndex[0][0]:=0;
   downIndex[0][1]:=0;
   downIndex[0][2]:=0;

   downIndex[1][0]:=0;
   downIndex[1][1]:=0;
   downIndex[1][2]:=0;

   downIndex[2][0]:=0;
   downIndex[2][1]:=0;
   downIndex[2][2]:=0;
   downIndex[3][0]:=0;

   downIndex[3][1]:=0;
   downIndex[3][2]:=0;

   downIndex[4][0]:=0;
   downIndex[4][1]:=0;
   downIndex[4][2]:=0;

    Chart2.Width:=Panel2.Width div 2;
    Chart1.Width:=Chart2.Width;
    Panel3.Height:= Height div 2;

    {$IFDEF VER2}
       drawnumber:=TStringList.Create;
        drawnumber.Add('0');
        drawnumber.Add('0');
        drawnumber.Add('0');
        drawnumber.Add('0');
        drawnumber.Add('0');
       startThread(0);
    {$ENDIF}
    {$IFDEF ADMIN}
       {Label2.Visible:=True;
       cxSpinEdit2.Visible:=True;

       Label3.Visible:=True;
       cxSpinEdit3.Visible:=True;
       Button2.Visible:=True;

       Button4.Visible:=True;
       Button6.Visible:=True;
       Button5.Visible:=True;

       }

    {$ENDIF}

end;

procedure Tchardatafrm.saveconfig;
var
  ifile:TIniFile;
begin
  cxTextEdit1.Properties.OnEditValueChanged:=nil;
  cxTextEdit2.Properties.OnEditValueChanged:=nil;
  cxTextEdit3.Properties.OnEditValueChanged:=nil;
  cxTextEdit4.Properties.OnEditValueChanged:=nil;
  cxSpinEdit1.Properties.OnEditValueChanged:=nil;
  cxTextEdit6.Properties.OnEditValueChanged:=nil;
  cxTextEdit7.Properties.OnEditValueChanged:=nil;
  cxTextEdit8.Properties.OnEditValueChanged:=nil;
  Edit3.OnChange:=nil;
  Edit4.OnChange:=nil;
  Edit5.OnChange:=nil;

  CheckBox3.OnClick:=nil;
  CheckBox4.OnClick:=nil;
  CheckBox2.OnClick:=nil;

  cxTextEdit1.PostEditValue;
  cxTextEdit2.PostEditValue;
  cxTextEdit3.PostEditValue;
  cxTextEdit4.PostEditValue;
  cxTextEdit5.PostEditValue;

  ifile:=TIniFile.Create(GetCurrentDir+'\cfg.ini');
  try
    ifile.WriteString('cfg','user'+inttostr(FTYpe),cxTextEdit4.Text);
    ifile.WriteString('cfg','listion1'+inttostr(FTYpe),cxTextEdit1.Text);
    ifile.WriteString('cfg','listion2'+inttostr(FTYpe),cxTextEdit2.Text);
    ifile.WriteString('cfg','listion3'+inttostr(FTYpe),cxTextEdit3.Text);

    ifile.WriteString('cfg','downtext1'+inttostr(FTYpe),cxTextEdit7.Text);
    ifile.WriteString('cfg','downtext2'+inttostr(FTYpe),cxTextEdit6.Text);
    ifile.WriteString('cfg','downtext3'+inttostr(FTYpe),cxTextEdit8.Text);

    ifile.WriteString('cfg','caseFlag1'+inttostr(FTYpe),Edit3.Text);
    ifile.WriteString('cfg','caseFlag2'+inttostr(FTYpe),Edit4.Text);
    ifile.WriteString('cfg','caseFlag3'+inttostr(FTYpe),Edit5.Text);

    ifile.WriteString('cfg','startdate'+inttostr(FTYpe),cxSpinEdit2.Text);

    ifile.WriteString('cfg','enddate'+inttostr(FTYpe),cxSpinEdit3.Text);

    ifile.WriteString('cfg','listion99'+inttostr(FTYpe),cxTextEdit5.Text);

    ifile.WriteString('cfg','look'+inttostr(FTYpe),cxSpinEdit1.Text);
    if PostThread <>nil then
    PostThread.Flimite:=  cxSpinEdit1.Value;
    if CheckBox2.Checked then
       ifile.WriteInteger('cfg','notecheck2'+inttostr(FTYpe),1)
    else
       ifile.WriteInteger('cfg','notecheck2'+inttostr(FTYpe),0);

    if CheckBox3.Checked then
       ifile.WriteInteger('cfg','notecheck3'+inttostr(FTYpe),1)
    else
       ifile.WriteInteger('cfg','notecheck3'+inttostr(FTYpe),0);

    if CheckBox4.Checked then
       ifile.WriteInteger('cfg','notecheck4'+inttostr(FTYpe),1)
    else
       ifile.WriteInteger('cfg','notecheck4'+inttostr(FTYpe),0);

  finally
ifile.Free;
    cxTextEdit1.Properties.OnEditValueChanged:= cxTextEdit1PropertiesEditValueChanged;
    cxTextEdit2.Properties.OnEditValueChanged:= cxTextEdit1PropertiesEditValueChanged;
    cxTextEdit3.Properties.OnEditValueChanged:= cxTextEdit1PropertiesEditValueChanged;
    cxTextEdit4.Properties.OnEditValueChanged:= cxTextEdit1PropertiesEditValueChanged;
    cxSpinEdit1.Properties.OnEditValueChanged:= cxSpinEdit1PropertiesEditValueChanged;
    CheckBox2.OnClick:=  CheckBox3Click;
    CheckBox3.OnClick:=  CheckBox3Click;
    CheckBox4.OnClick:=  CheckBox3Click;

    cxTextEdit6.Properties.OnEditValueChanged:=cxTextEdit6PropertiesEditValueChanged;
    cxTextEdit7.Properties.OnEditValueChanged:=cxTextEdit6PropertiesEditValueChanged;
    cxTextEdit8.Properties.OnEditValueChanged:=cxTextEdit6PropertiesEditValueChanged;

    Edit3.OnChange:=Edit3Change;
    Edit4.OnChange:=Edit4Change;
    Edit5.OnChange:=Edit5Change;

  end;

end;

procedure Tchardatafrm.cxTextEdit1PropertiesEditValueChanged(
  Sender: TObject);
begin
   saveconfig;
end;

procedure Tchardatafrm.loadconfig;
var
  ifile:TIniFile;
begin
  cxTextEdit1.Properties.OnEditValueChanged:=nil;
  cxTextEdit2.Properties.OnEditValueChanged:=nil;
  cxTextEdit3.Properties.OnEditValueChanged:=nil;
  cxTextEdit4.Properties.OnEditValueChanged:=nil;
  cxTextEdit5.Properties.OnEditValueChanged:=nil;
  cxTextEdit6.Properties.OnEditValueChanged:=nil;
  cxTextEdit7.Properties.OnEditValueChanged:=nil;
  cxTextEdit8.Properties.OnEditValueChanged:=nil;

  cxSpinEdit2.Properties.OnEditValueChanged:=nil;
  cxSpinEdit3.Properties.OnEditValueChanged:=nil;

  Edit3.OnChange:=nil;
  Edit4.OnChange:=nil;
  Edit5.OnChange:=nil;

  CheckBox3.OnClick:=nil;
  CheckBox4.OnClick:=nil;
  CheckBox2.OnClick:=nil;
  cxSpinEdit1.Properties.OnEditValueChanged:= nil;

  ifile:=TIniFile.Create(GetCurrentDir+'\cfg.ini');
  try

    cxTextEdit4.Text:= ifile.ReadString('cfg','user'+inttostr(FTYpe),'') ;

    cxTextEdit1.Text:=ifile.ReadString('cfg','listion1'+inttostr(FTYpe),'');
    cxTextEdit2.Text:=ifile.ReadString('cfg','listion2'+inttostr(FTYpe),'');
    cxTextEdit3.Text:=ifile.ReadString('cfg','listion3'+inttostr(FTYpe),'');

    cxTextEdit5.Text:=ifile.ReadString('cfg','listion99'+inttostr(FTYpe),'');

    cxTextEdit7.Text:=ifile.ReadString('cfg','downtext1'+inttostr(FTYpe),'');
    cxTextEdit6.Text:=ifile.ReadString('cfg','downtext2'+inttostr(FTYpe),'');
    cxTextEdit8.Text:=ifile.ReadString('cfg','downtext3'+inttostr(FTYpe),'');

    cxSpinEdit2.Text:=ifile.ReadString('cfg','startdate'+inttostr(FTYpe),'');

    cxSpinEdit3.Text:=ifile.ReadString('cfg','enddate'+inttostr(FTYpe),'');

    cxSpinEdit1.Text:= ifile.ReadString('cfg','look'+inttostr(FTYpe),'10');
    cxSpinEdit1.PostEditValue;

    Edit3.Text:= ifile.ReadString('cfg','caseFlag1'+inttostr(FTYpe),'');
    Edit4.Text:= ifile.ReadString('cfg','caseFlag2'+inttostr(FTYpe),'');
    Edit5.Text:= ifile.ReadString('cfg','caseFlag3'+inttostr(FTYpe),'');

    if ifile.ReadInteger('cfg','notecheck2'+inttostr(FTYpe),0)=0 then
        CheckBox2.Checked:=false
    else
        CheckBox2.Checked:=True;

    if ifile.ReadInteger('cfg','notecheck3'+inttostr(FTYpe),0)=0 then
        CheckBox3.Checked:=false
    else
        CheckBox3.Checked:=True;

    if ifile.ReadInteger('cfg','notecheck4'+inttostr(FTYpe),0)=0 then
        CheckBox4.Checked:=false
    else
        CheckBox4.Checked:=True;        

  finally
ifile.Free;
    cxTextEdit1.Properties.OnEditValueChanged:= cxTextEdit1PropertiesEditValueChanged;
    cxTextEdit2.Properties.OnEditValueChanged:= cxTextEdit1PropertiesEditValueChanged;
    cxTextEdit3.Properties.OnEditValueChanged:= cxTextEdit1PropertiesEditValueChanged;
    cxTextEdit4.Properties.OnEditValueChanged:= cxTextEdit1PropertiesEditValueChanged;
    cxTextEdit5.Properties.OnEditValueChanged:=cxTextEdit1PropertiesEditValueChanged;
    CheckBox2.OnClick:=  CheckBox3Click;
    CheckBox3.OnClick:=  CheckBox3Click;
    CheckBox4.OnClick:=  CheckBox3Click;
    cxTextEdit6.Properties.OnEditValueChanged:=cxTextEdit6PropertiesEditValueChanged;
    cxTextEdit7.Properties.OnEditValueChanged:=cxTextEdit6PropertiesEditValueChanged;
    cxTextEdit8.Properties.OnEditValueChanged:=cxTextEdit6PropertiesEditValueChanged;
    cxSpinEdit2.Properties.OnEditValueChanged:=cxSpinEdit2PropertiesEditValueChanged;
    cxSpinEdit3.Properties.OnEditValueChanged:=cxSpinEdit3PropertiesEditValueChanged;
回复

使用道具 举报

0

主题

2

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2022-11-26 16:27:13 | 显示全部楼层
这壳加了个寂寞,公司白花钱了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋| 黑客通

GMT+8, 2025-4-6 13:59 , Processed in 0.080329 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2020, LianLian.

快速回复 返回顶部 返回列表