Skip to content

remove the rsa command, make factor command only query factordb #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,6 @@ you can supply values the most common prefixes i.e. n= -n= --n=

multiple values can be supplied as a list or with multiple argument prefixes e.g. -n=1,2,3 or -n=1 -n=2 -n=3

this command opportunistically makes use of the following tools to perform factorization:

- gmp-ecm
- pari-gp

for example:
```bash
$ ret factor -n=1807415580361109435231633835400969
Expand Down Expand Up @@ -448,44 +443,6 @@ you can also manually remove ctftime urls from this list by directly editing `~/

---

### 🔐 <u>rs</u>a

```
$ ret rsa [--p] [--q] [--e] [--d] [--n] [--c]
```

solve simple rsa tasks with ret

this command works by applying strategies to the given parameters that look for plaintext that consists of entirely ascii printable bytes

as a result it is well suited to finding flags for ctf tasks but not as a general purpose integer factorization tool

arguments can be supplied as either base 10 or base 16 strings and the base will be inferred automatically

for example FEED01234 will be treated as a base 16 string and 123456789 will be treated as a base 10 string

you can supply arguments the most common prefixes i.e. x= -x= --x= where x is one of {p, q, e, d, n, c}

multiple values can be supplied as a list or with multiple argument prefixes e.g. -n=1,2,3 or -n=1 -n=2 -n=3

this command opportunistically makes use of the following tools to perform compute intensive factorization:

- gmp-ecm
- pari-gp

note: this command is essentially a work in progress as strategies are added over time

for example:
```bash
$ ret rsa -n=1807415580361109435231633835400969 -e=65537 -c=1503532357945764445345675481376484
$ ret rsa -n=0x591ccab6e6a72f019cf942f99f09 -e=0x10001 -c=0x4a213f10d6c08b78ff5c0562e6e4
$ ret rsa -n=147879229115615272273161474028448405953 -e=3 -c=11160123069268350498833916853402276143
```

🔗 https://github.com/rerrorctf/ret/blob/main/commands/rsa.go

---

### 🌐 <u>sh</u>are

```
Expand Down
73 changes: 4 additions & 69 deletions commands/factor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func init() {
List: false,
},
},
SeeAlso: []string{"rsa"}})
SeeAlso: nil})
}

func FactorHelp() string {
Expand All @@ -39,10 +39,6 @@ func FactorHelp() string {
"you can supply values the most common prefixes i.e. " + theme.ColorBlue + "n= -n= --n= " + theme.ColorReset + "\n\n" +
"multiple values can be supplied as a list or with multiple argument prefixes e.g. " + theme.ColorBlue + "-n=1,2,3 or -n=1 -n=2 -n=3" + theme.ColorReset + "\n\n" +

"this command opportunistically makes use of the following tools to perform factorization:\n\n" +
" - gmp-ecm\n" +
" - pari-gp\n\n" +

"for example:\n" +
"```bash\n" +
theme.ColorGray + "$ " + theme.ColorBlue + "ret factor -n=1807415580361109435231633835400969\n" + theme.ColorReset +
Expand Down Expand Up @@ -81,7 +77,7 @@ func Factor(args []string) {
go func() {
defer wg.Done()

factors, url, err := util.FactorDB(n)
status, factors, url, err := util.FactorDB(n)
if err != nil {
log.Fatalf("💥 "+theme.ColorRed+" error"+theme.ColorReset+": %v\n", err)
}
Expand All @@ -97,71 +93,10 @@ func Factor(args []string) {
diff := time.Now().Sub(startTime)

fmt.Printf(theme.ColorGreen+"🪓 [factordb]"+theme.ColorReset+" in "+
theme.ColorYellow+"%v"+theme.ColorGray+" %v"+theme.ColorReset+"\n"+"%v\n\n",
diff, url, factors)
theme.ColorYellow+"%v"+theme.ColorGray+" %v"+theme.ColorReset+"\n"+"[%s] %v\n",
diff, url, status, factors)
}()
}

if util.CheckIfECMInstalled() {

for _, n := range N {
wg.Add(1)

go func() {
defer wg.Done()

factors, cmdStr, err := util.FactorWithECM(n)
if err != nil {
log.Fatalf("💥 "+theme.ColorRed+" error"+theme.ColorReset+": %v\n", err)
}

if factors == nil {
return
}

if len(factors) == 0 {
return
}

diff := time.Now().Sub(startTime)

fmt.Printf(theme.ColorGreen+"🪓 [ecm]"+theme.ColorReset+" in "+
theme.ColorYellow+"%v"+theme.ColorGray+" %v"+theme.ColorReset+"\n"+"%v\n\n",
diff, cmdStr, factors)
}()
}
}

if util.CheckIfPariInstalled() {

for _, n := range N {
wg.Add(1)

go func() {
defer wg.Done()

factors, cmdStr, err := util.FactorWithPari(n)
if err != nil {
log.Fatalf("💥 "+theme.ColorRed+" error"+theme.ColorReset+": %v\n", err)
}

if factors == nil {
return
}

if len(factors) == 0 {
return
}

diff := time.Now().Sub(startTime)

fmt.Printf(theme.ColorGreen+"🪓 [gp-pari]"+theme.ColorReset+" in "+
theme.ColorYellow+"%v"+theme.ColorGray+" %v"+theme.ColorReset+"\n"+"%v\n\n",
diff, cmdStr, factors)
}()
}

}

wg.Wait()
}
109 changes: 0 additions & 109 deletions commands/rsa.go

This file was deleted.

Loading