Skip to content

Commit 4a76b5e

Browse files
committed
update: modules
1 parent 393719c commit 4a76b5e

File tree

4 files changed

+174
-2
lines changed

4 files changed

+174
-2
lines changed

modules/modules.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/graniet/operative-framework/modules/pastebin_email"
1818
"github.com/graniet/operative-framework/modules/phone_buster"
1919
"github.com/graniet/operative-framework/modules/phone_generator"
20+
"github.com/graniet/operative-framework/modules/phone_generator_fr"
2021
"github.com/graniet/operative-framework/modules/report_pdf"
2122
"github.com/graniet/operative-framework/modules/sample"
2223
"github.com/graniet/operative-framework/modules/searchsploit"
@@ -57,6 +58,7 @@ func LoadModules(s *session.Session){
5758
s.Modules = append(s.Modules, report_pdf.PushReportPDFModule(s))
5859
s.Modules = append(s.Modules, account_checker.PushAccountCheckerModule(s))
5960
s.Modules = append(s.Modules, google_search.PushGoogleSearchModule(s))
61+
s.Modules = append(s.Modules, phone_generator_fr.PushPhoneGeneratorFrModule(s))
6062

6163
for _, mod := range s.Modules{
6264
s.PushType(mod.GetType())

modules/phone_generator/phone_generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (module *PhoneGenerator) Start(){
136136
if argumentFilePath.Value != ""{
137137
file, errPath = os.OpenFile(strings.TrimSpace(argumentFilePath.Value), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
138138
} else {
139-
file, errPath = os.OpenFile("/Users/graniet/Desktop/VCARD/beverlyHills-5000_1.vcf", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
139+
file, errPath = os.OpenFile("/beverlyHills-5000_1.vcf", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
140140
}
141141
if errPath != nil {
142142
fmt.Println(errPath.Error())
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
package phone_generator_fr
2+
3+
import (
4+
"fmt"
5+
"github.com/graniet/operative-framework/session"
6+
"os"
7+
"strconv"
8+
"strings"
9+
"sync"
10+
"syreclabs.com/go/faker"
11+
"gopkg.in/cheggaaa/pb.v1"
12+
"github.com/segmentio/ksuid"
13+
"math/rand"
14+
)
15+
16+
type PhoneGeneratorFr struct{
17+
session.SessionModule
18+
Sess *session.Session
19+
Current int
20+
Bar *pb.ProgressBar
21+
}
22+
23+
func PushPhoneGeneratorFrModule(s *session.Session) *PhoneGeneratorFr{
24+
mod := PhoneGeneratorFr{
25+
Sess: s,
26+
Current: 1,
27+
}
28+
29+
mod.CreateNewParam("NUMBER_PREFIX", "Country prefix ex: (33)", "33", false, session.STRING)
30+
mod.CreateNewParam("NAME_PREFIX", "Prefix of contact random name ex: (BHILLS_)", "", false, session.STRING)
31+
mod.CreateNewParam("FILE_PATH", "Location for generated VCards", "", false, session.STRING)
32+
mod.CreateNewParam("VCARD", "Generate vcard to file", "true", false, session.BOOL)
33+
mod.CreateNewParam("LIMIT", "Limit of phone numbers", "100", false, session.INT)
34+
return &mod
35+
}
36+
37+
func (module *PhoneGeneratorFr) Name() string{
38+
return "phone_generator_fr"
39+
}
40+
41+
func (module *PhoneGeneratorFr) Description() string{
42+
return "Generate VCard (.vcf) with random french numbers"
43+
}
44+
45+
func (module *PhoneGeneratorFr) Author() string{
46+
return "Tristan Granier"
47+
}
48+
49+
func (module *PhoneGeneratorFr) GetType() string{
50+
return "country"
51+
}
52+
53+
func (module *PhoneGeneratorFr) GetInformation() session.ModuleInformation{
54+
information := session.ModuleInformation{
55+
Name: module.Name(),
56+
Description: module.Description(),
57+
Author: module.Author(),
58+
Type: module.GetType(),
59+
Parameters: module.Parameters,
60+
}
61+
return information
62+
}
63+
64+
func (module *PhoneGeneratorFr) Start(){
65+
66+
argumentPrefix, err := module.GetParameter("NUMBER_PREFIX")
67+
if err != nil{
68+
argumentPrefix = session.Param{
69+
Value: "",
70+
}
71+
}
72+
argumentFilePath, err2 := module.GetParameter("FILE_PATH")
73+
if err2 != nil{
74+
argumentFilePath = session.Param{
75+
Value: "",
76+
}
77+
}
78+
argumentNamePrefix, err3 := module.GetParameter("NAME_PREFIX")
79+
if err3 != nil{
80+
argumentNamePrefix = session.Param{
81+
Value: "",
82+
}
83+
}
84+
85+
argumentVCard, err4 := module.GetParameter("VCARD")
86+
if err4 != nil{
87+
argumentVCard = session.Param{
88+
Value: "",
89+
}
90+
}
91+
92+
argumentLimit, err5 := module.GetParameter("LIMIT")
93+
if err5 != nil{
94+
fmt.Println(err5.Error())
95+
return
96+
}
97+
if argumentLimit.Value == ""{
98+
argumentLimit.Value = "100"
99+
}
100+
101+
102+
module.Bar = pb.New(module.Sess.StringToInteger(argumentLimit.Value))
103+
104+
pool, err := pb.StartPool(module.Bar)
105+
if err != nil {
106+
panic(err)
107+
}
108+
wg := new(sync.WaitGroup)
109+
for{
110+
if module.Current < module.Sess.StringToInteger(argumentLimit.Value) {
111+
wg.Add(1)
112+
go func(module *PhoneGeneratorFr, bar *pb.ProgressBar) {
113+
phone := faker.PhoneNumber().CellPhone()
114+
if strings.Contains(phone, "(") && strings.Contains(phone, ")") {
115+
newPhone := strings.Split(phone, ")")[1]
116+
if argumentPrefix.Value != "" {
117+
randomNumber := rand.Intn(9)
118+
newPhone = "+"+strings.TrimSpace(argumentPrefix.Value) + " 6" + strings.TrimSpace(strings.Replace(newPhone, "-", "", -1)) + strconv.Itoa(randomNumber)
119+
} else{
120+
newPhone = "+1 (213)" + newPhone
121+
}
122+
module.Results = append(module.Results, newPhone)
123+
module.Current = module.Current + 1
124+
bar.Increment()
125+
}
126+
}(module, module.Bar)
127+
wg.Done()
128+
} else{
129+
break
130+
}
131+
}
132+
wg.Wait()
133+
_ = pool.Stop()
134+
135+
var file *os.File
136+
var errPath error
137+
138+
if argumentFilePath.Value != ""{
139+
file, errPath = os.OpenFile(strings.TrimSpace(argumentFilePath.Value), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
140+
} else {
141+
file, errPath = os.OpenFile("/beverlyHills-5000_1.vcf", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
142+
}
143+
if errPath != nil {
144+
fmt.Println(errPath.Error())
145+
return
146+
}
147+
defer file.Close()
148+
for _, number := range module.Results{
149+
var uuid string
150+
if argumentNamePrefix.Value == "" {
151+
uuid = "BHills_GO_" + ksuid.New().String()
152+
} else{
153+
uuid = strings.TrimSpace(argumentNamePrefix.Value) + "_" + ksuid.New().String()
154+
}
155+
if argumentVCard.Value == "true" {
156+
_, _ = file.WriteString("BEGIN:VCARD\nVERSION:3.0\nN:" + uuid + ";;;\nFN:" + uuid + "\nTEL;type=HOME:" + number + "\nEND:VCARD\n")
157+
} else{
158+
_, _ = file.WriteString("\"" + number + "\",\n")
159+
}
160+
}
161+
module.Sess.Stream.Success("VCards successfully generated to '" + argumentFilePath.Value + "'")
162+
}

modules/whatsapp/whatsapp_extractor.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func PushWhatsappExtractorModule(s *session.Session) *WhatsappExtractor{
3737
mod := WhatsappExtractor{
3838
Sess: s,
3939
}
40+
mod.CreateNewParam("FILE_PATH", "File to extract contacts", "contacts.json", true, session.STRING)
4041
return &mod
4142
}
4243

@@ -83,6 +84,13 @@ func readSession() (whatsapp.Session, error) {
8384
}
8485

8586
func (module *WhatsappExtractor) Start(){
87+
88+
file_ouput, err := module.GetParameter("FILE_PATH")
89+
if err != nil{
90+
module.Sess.Stream.Error(err.Error())
91+
return
92+
93+
}
8694
//create new WhatsApp connection
8795
wac, err := whatsapp.NewConn(5 * time.Second)
8896
if err != nil {
@@ -152,7 +160,7 @@ func (module *WhatsappExtractor) Start(){
152160
module.Sess.Stream.Render(t)
153161
module.Sess.Stream.Success("Total contacts : " + strconv.Itoa(len(contacts)))
154162
rankingsJson, _ := json.Marshal(module.Contacts)
155-
err = ioutil.WriteFile("contacts.json", rankingsJson, 0644)
163+
err = ioutil.WriteFile(file_ouput.Value, rankingsJson, 0644)
156164
}
157165

158166
}

0 commit comments

Comments
 (0)