Skip to content

Commit

Permalink
tttt
Browse files Browse the repository at this point in the history
  • Loading branch information
@ committed Aug 14, 2021
1 parent 3646c1a commit f106343
Show file tree
Hide file tree
Showing 22 changed files with 432 additions and 250 deletions.
6 changes: 3 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## fd

#### 简要介绍
* **要是你看不懂中文可以使用chrome翻译功能**
* **English can use chrome translation or [click english doc](README_EN.MD)**
* **frida 运行时(不需要python,只有单一个文件)**
* **fd 使用fd前请确认手机上有frida-server**
* **优雅的使用webstorm开发(拥有智能完美的智能提示,内置了一些调试库) **
Expand All @@ -10,7 +10,6 @@
![](gif/run.webp)

#### a brief introdction
* **English can use chrome translation or [click english doc](README_EN.MD)**
* **frida runtime (no python required, only a single file)**
* **fd need you phone require frida-server**

Expand Down Expand Up @@ -40,7 +39,8 @@
3. 搜索: frida 并且安装
4. 根据系统下载fd: https://github.com/a97077088/fd/releases
5. 数据线链接到电脑
6. fd bagbak 通讯录 //通讯录需要手动打开并且置于前台
6. fd bagbak 通讯录 //通讯录需要手动打开并且置于前台,fd仅以附加模式工作
7. 或者: fd bagbak com.apple.MobileAddressBook //通讯录需要手动打开并且置于前台,fd仅以附加模式工作
//Contacts.app现在出现在你的目录
````

Expand Down
3 changes: 2 additions & 1 deletion README_EN.MD
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## fd

#### 简要介绍
* **[中文文档点击这里](README.MD)**
* **frida 运行时(不需要python,只有单一个文件)**
* **fd 使用fd前请确认手机上有frida-server**
* **优雅的使用webstorm开发(拥有智能完美的智能提示,内置了一些调试库) **

#### a brief introdction
* **[中文文档点击这里](README_EN.MD)**
* **frida runtime (no python required, only a single file)**
* **fd need you phone require frida-server**
* **Elegant use of webstorm development (with smart and perfect smart tips, some built-in debugging libraries) **
Expand Down Expand Up @@ -42,6 +42,7 @@
4. Download according to the system fd,(windows or linux or macos?): https://github.com/a97077088/fd/releases
5. Data cable link to computer
6. shell (The address book needs to be opened manually and placed in the front desk):fd bagbak 通讯录
7. or: fd bagbak com.apple.MobileAddressBook
//dump file:Contacts.app Now it appears in your directory
````

Expand Down
85 changes: 73 additions & 12 deletions run.go → falg_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"bytes"
"context"
"errors"
"flag"
"fmt"
frida_go "github.com/a97077088/frida-go"
jsoniter "github.com/json-iterator/go"
Expand All @@ -15,12 +17,50 @@ import (
"sync"
)

var param_run_name= FlagRun.String("name","","调试进程名称,比如 通讯录,(lsps的结果中可以看到)")
var param_run_pid= FlagRun.Uint("pid",0,"进程pid")
var param_run_jsbyte= FlagRun.Bool("jsbyte",false,"是否使用编译过的js 字节码")
var param_run_devi= FlagRun.String("devi","","设备")
var param_run_restart=FlagRun.Bool("restart",false,"restart app")
var FlagRun =flag.NewFlagSet("run",flag.ExitOnError)
func init(){
FlagRun.Usage= func() {
fmt.Fprintf(FlagRun.Output(), "============== 脚本调试 使用方法:%s\n", "run 1.js -name 通讯录")
FlagRun.PrintDefaults()
}
}

func FlagRunMain(args []string)error{



if len(args)<1{
fmt.Println("解析js文件失败")
FlagRun.Usage()
return nil
}
a1:=args[0]
param_jspath:=a1
FlagRun.Parse(args[1:])
if *param_run_name==""&&*param_run_pid==0{
fmt.Println("name参数,和pid同时解析失败")
FlagRun.Usage()
return nil
}
if FlagRun.Parsed(){
return NewRun().Run(RunParam{JsPath: param_jspath,Name:*param_run_name,JsByte: *param_run_jsbyte,Devi: *param_run_devi,Pid:*param_run_pid,ReStart: *param_run_restart})
}
return errors.New("run命令解析失败")
}


type RunParam struct {
Pid uint
Name string
JsPath string
JsByte bool
Devi string
ReStart bool
}
type Run struct {

Expand All @@ -41,28 +81,51 @@ func (l *Run) Run(param RunParam) error {
jsos:=jssys.Get("os")
fmt.Printf("内核平台:%s cpu构架:%s 当前系统:%s(%s) 设备名称:%s 权限:%s \n",jssys.Get("platform").ToString(),jssys.Get("arch").ToString(),jsos.Get(1).Get("id").ToString(),jsos.Get(0).Get("version").ToString(),jssys.Get("name").ToString(),jssys.Get("access").ToString())

var pid uint
if param.Pid==0{
p,err:=d.GetProcessByName(param.Name,frida_go.ProcessMatchOptions{})
var app *frida_go.ApplicationDetails
pid:=param.Pid

if pid==0{
app,pid,err=GetName(d,param.Name)
if err!=nil{
return err
return err
}
fmt.Printf("调试进程:%s 进程id:%d 脚本:%s\n",p.Name(),p.Pid(),param.JsPath)
pid=p.Pid()
}else{
pid=param.Pid
fmt.Printf("进程id:%d 脚本:%s\n",pid,param.JsPath)
}




spawnCtx,resumeOK:=context.WithCancel(context.TODO())
if app==nil{
fmt.Printf("进程id:%d 脚本:%s\n",pid,param.JsPath)
}else{
if param.ReStart{
d.Kill(pid)
pid=0
}
if pid==0{
pid,err=d.Spawn(app.Identifier(),frida_go.SpawnOptions{})
if err!=nil{
return err
}
go func() {
select {
case <-spawnCtx.Done():
d.Resume(pid)
}
}()
}
fmt.Printf("调试进程:%s 进程id:%d 脚本:%s\n",app.Name(),pid,param.JsPath)
}


session,err:=d.Attach(pid,frida_go.SessionOptions{})
if err!=nil{
return err
}
defer session.Detach()
//fmt.Println("download file example: send({\"type\":\"download\",\"path\":\"test/test.txt\",\"append\":true},new Uint8Array([0x01]).buffer)")


_,err=os.Stat("./agent/box")
if err==nil{
tmplatebox,err:=frida_agent_example.ReadFile("frida-agent-example/agent/box.ts")
Expand Down Expand Up @@ -102,9 +165,6 @@ func (l *Run) Run(param RunParam) error {
return err
}
}



fd,err:=ioutil.ReadFile(param.JsPath)
if err!=nil{
return err
Expand Down Expand Up @@ -186,6 +246,7 @@ func (l *Run) Run(param RunParam) error {
return err
}
defer sc.UnLoad()
resumeOK()



Expand Down
Loading

0 comments on commit f106343

Please sign in to comment.