-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
4026 lines (3602 loc) · 168 KB
/
mainwindow.cpp
File metadata and controls
4026 lines (3602 loc) · 168 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "mainwindow.h"
#include "ui_mainwindow.h"
#define IMGTAB 1
#define TABMON 2
#define IMGTBOX 2
#define STRTAB 0
#define TBOXLOG 3
#define TBOXSTR 0
#define EXITCRASH 1
#define STOPPED -2
#define EXITOK 0
#define ABORTED 10
#define WRITE 2
#define READ 1
/*
objdump -d binario - encontra os métodos e seus nomes
The Defense Cyber Crime Center (DC3) is an United States Department of Defense agency that provides digital forensics support
to the DoD and to other law enforcement agencies. DC3's main focus is in criminal, counterintelligence, counterterrorism, and
fraud investigations from the Defense Criminal Investigative Organizations (DCIOs), DoD counterintelligence groups, and various
Inspector General groups. The Air Force Office of Special Investigations is the executive agent of DC3.[1]
http://en.wikipedia.org/wiki/Department_of_Defense_Cyber_Crime_Center
---------------------------------
/home/djames/Qt/5.3/gcc_64/bin/lupdate -pro DjamesWatson.pro
o lrelease é feito pelo linguist, nao precisa se preocupar com isso
*/
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->PID = QString::number(QCoreApplication::applicationPid());
QFile pid("/var/log/DWatson/"+this->PID);
if (pid.exists()){
this->close();
}
pid.open(QIODevice::Text|QIODevice::WriteOnly);
pid.write(dateTimeNowString().toUtf8()+"\n");
pid.close();
//QTimer::singleShot(1000, this, SLOT(showMaximized()));
//this->showMaximized();
//QFontDatabase::addApplicationFont("/usr/share/fonts/truetype/droid/DroidSans.ttf");
//QFontDatabase::addApplicationFont("/usr/share/fonts/truetype/droid/DroidSans-Bold.ttf");
this->common = new Common();
this->wiper = new Wiping();
this->gpt = new GPTandFormat(0,this->common);
this->sysInfo = new SystemInfo();
this->bitwise = new BitWiseCopy();
this->graph = new GraphRealTime();
this->fingerprint = new FingerPrintAndTraces();
this->doc = new documentation();
this->screenshot = new Screenshot(this);
this->screencast = new Screencast();
this->pbarUndefVal = new ProgressBarUndefinedValue();
this->autoRenameShot = new AutoRenameShot();
this->ewf = new ewfRelat();
this->ewfAcquiring = new ExpertWitnessFormat();
this->crypt = new Encrypt();
this->iostat = new IOStats();
//image viewer
this->imageLabel1 = new QLabel;
this->imageLabel2 = new QLabel;
this->imageLabel3 = new QLabel;
this->imageLabel4 = new QLabel;
this->showLogInDetailWindowIfStringsOff = false;
//valores carregados pelo qsettings
this->Settings();
QDateTime now = QDateTime::currentDateTime();
ui->dateTimeEdit->setDateTime(now);
//Componentes da UI
ui->progressBar->setValue(0);
ui->progressBar->setDisabled(true);
ui->radio_md5->setEnabled(false);
ui->radio_sha->setEnabled(false);
ui->radioButton_bw_src2file->setChecked(true);
ui->radioButton_show_dst_data->setEnabled(false);
ui->radioButton_show_src_data->setEnabled(false);
ui->comboBox_hash->setEnabled(false);
ui->comboBox_Target_bitwise->setEnabled(false);
ui->comboBox_target_format->setEnabled(false);
ui->comboBox_bitwiseTools->setEnabled(false);
ui->checkBoxHashEmArquivo->setEnabled(false);
ui->checkBox_hash->setEnabled(false);
ui->checkBox_gerarLog->setEnabled(false);
ui->checkBox_readOnly_bw->setChecked(true);
ui->checkBox_wipe->setDisabled(true);
ui->pushButton_colect->setDisabled(true);
ui->pushButton_selecionar->setDisabled(true);
ui->pushButton_show_data->setDisabled(true);
ui->pushButton_datetime->setDisabled(true);
//ui->groupBox_ddrescue->setDisabled(true);
ui->frame_split->setEnabled(false);
ui->groupBox_imgInfo->setDisabled(true);
//Textos da Interface
ui->label_image->setStyleSheet("color: gray;");
ui->label_image->setText(tr("(Clique no botão ao lado para selecionar imagem)"));
//ToolBox text
ui->toolBox->setItemText(0,tr("..."));
ui->toolBox->setItemText(1,"HDDs/SSDs");
ui->toolBox->setItemText(2,tr("Geração de Imagem"));
ui->toolBox->setItemText(3,tr("Log"));
ui->toolBox->setItemText(4,tr("Ajustes"));
//divisao de imagens raw
ui->checkBox_split->setText(tr("Dividir a cada"));
//toolbox, aba log log...
ui->radioButton_off->setChecked(true);
//TabWidget
ui->tabWidget->setTabText(3,tr("Documentação"));
this->enableDisableItems(false);
ui->toolBox->setItemEnabled(0,false);
//Combo SHA
QStringList shaType;
shaType << "Sha1" << "Sha224" << "Sha256" << "Sha384" << "Sha512"; //TODO: << "Sha3_224" << "Sha3_256" << "Sha3_384" << "Sha3_512";
ui->comboBox_hash->addItems(shaType);
//Titulo da mainWindow
this->setWindowTitle(tr("Djames Watson 1.0 - Cadeia de Custódia - 04.2015"));
ui->progressBar->setMaximum(100);
ui->radio_sha->setChecked(true);
QStringList feed = this->common->connectedDevices(false,"none");
if (feed.length() > 0){
feed.removeAt(0);
ui->listWidget_medias->addItems(feed);
}
this->connections();
//!Essa thread roda constantemente, coletando variáveis de ambiente para exibição na aba Monitor.
QString val = ui->label_executing_tasks->text()+"Monitor ";
ui->label_executing_tasks->setText(val);
this->sysInfo->start();
//Atalhos de teclado como esse deverão ser implementados em um método para tentar despoluir o construtor dessa classe
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this,SLOT(screenShort()));
//Monitora as threads em execução
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(checkTasks()));
timer->start(5000);
QString d;
QString t;
QString fullVal = dateTimeNowString();
QRegExp rxDT("(\\d{2}:\\d{2}:\\d{2})");
rxDT.indexIn(fullVal);
t = rxDT.capturedTexts().last();
d = fullVal.remove(rxDT);
ui->label_date->setText(d);
ui->label_hour->setText(t);
ui->textEdit->setText(tr("Olá. Lembrarei sempre que para iniciar as operações, você deve selecionar um idioma, confirmar ou ajustar data e hora e confirmar em 'Ok'."));
//ui->textEdit->setStyleSheet("text-align:justify; background-color:transparent;");
ui->textEdit->setAlignment(Qt::AlignJustify);
QStringList docMenu;
docMenu << tr("0.0 - Introdução") << tr("1.0 - Liberando a Interface") << tr("2.0 - Apresentação da Interface");
docMenu << tr("2.1 - Responsividade interativa") << tr("2.2 - Auto limpeza da interface") << tr("3.0 - Componentes da Interface");
docMenu << tr("3.1 - Componentes de rodapé") << tr("3.2 - Monitor") << tr("4.0 - ScreenShot") << tr("5.0 - ScreenCast") << tr("6.0 - Identificação dos dispositivos");
docMenu << tr("7.0 - Dúvidas e Suporte") << tr("8.0 - Licença, direitos e fontes");
ui->comboBox_topics->addItems(docMenu);
//openssl enc types
QStringList encTypes;
encTypes<< "aes-256-cbc" << "aes-256-ecb" << "base64" << "bf";
encTypes<< "bf-cbc" << "bf-cfb" << "bf-ecb" << "bf-ofb";
encTypes<< "camellia-128-cbc" << "camellia-128-ecb" << "camellia-192-cbc" << "camellia-192-ecb";
encTypes<< "camellia-256-cbc" << "camellia-256-ecb" << "cast" << "cast-cbc";
encTypes<< "cast5-cbc" << "cast5-cfb" << "cast5-ecb" << "cast5-ofb";
encTypes<< "des" << "des-cbc" << "des-cfb" << "des-ecb";
encTypes<< "des-ede" << "des-ede-cbc" << "des-ede-cfb" << "des-ede-ofb";
encTypes<< "des-ede3" << "des-ede3-cbc" << "des-ede3-cfb" << "des-ede3-ofb";
encTypes<< "des-ofb" << "des3" << "desx" << "rc2";
encTypes<< "rc2-40-cbc" << "rc2-64-cbc" << "rc2-cbc" << "rc2-cfb";
encTypes<< "rc2-ecb" << "rc2-ofb" << "rc4" << "rc4-40";
encTypes<< "seed" << "seed-cbc" << "seed-cfb" << "seed-ecb";
encTypes<< "seed-ofb";
ui->comboBox_openSSL_type->addItems(encTypes);
//ocultos
ui->frame_relatorio->setVisible(false);
ui->label_description->setVisible(false);
ui->label_notes->setVisible(false);
this->shotsViewer();
}
int MainWindow::bitwiseValidator()
{
//-1 = inconsistencia na operacao, 0 = ok, 1 = cancelado pelo usuário
QMessageBox msg;
msg.setStyleSheet("QMessageBox{border: 2px solid; border-color: rgb(85, 170, 255);}");
//O target só é alimentado e habilitado se a origem já tiver sido escolhida,
//então são necessárias as duas condicionais separadas
if (ui->comboBox_Source_bitwise->currentText().contains("Dev")){
msg.setWindowTitle(tr("Origem não selecionada"));
msg.setText(tr("Você deve escolher origem e destino da cópia primeiro."));
msg.exec();
log(tr("[user] Origem não selecionada:").toUtf8());
return -1;
}
if (ui->comboBox_Target_bitwise->currentText().contains("Dev")){
msg.setWindowTitle(tr("Destino não selecionado"));
msg.setText(tr("Você deve escolher origem e destino da cópia primeiro."));
msg.exec();
log(tr("[user] Destino não escolhido:").toUtf8());
return -1;
}
//O código já protege a seleção de origem no destino, mas cuidado nunca é demais
//(caso algum dia a validação sofra alguma alteração, por exemplo)
if (ui->comboBox_Source_bitwise->currentText() == ui->comboBox_Target_bitwise->currentText() && !ui->comboBox_Source_bitwise->currentText().contains("Dev")){
msg.setWindowTitle(tr("Origem e destino iguais"));
msg.setText(tr("O destino não deve ser igual a origem. Verifique também se a seleção está correta."));
msg.exec();
log(tr("[warning] Erro grave: Src e Dst iguais").toUtf8());
return -1;
}
//ferramenta a utilizar na copia bitwise
if (ui->comboBox_bitwiseTools->currentIndex() == 0){
msg.setWindowTitle(tr("Escolha ferramenta de cópia"));
msg.setText(tr("Você não escolheu uma ferramenta para iniciar a cópia."));
msg.exec();
log(tr("[user] Ferramenta de cópia não selecionada:").toUtf8());
return -1;
}
return 0;
}
//TODO: pbar da origem e destino: testar no live pra ver se funciona
void MainWindow::monitorSettings(QString srcOrDst)
{
QProcess diskSize;
QStringList params;
QString dev,devRaw;
QString result;
//Disk /dev/sdd: 7803 MB, 7803174912 bytes
QRegExp rx("Disk\\s{1,}/dev/sd\\w:\\s{1,}(\\d{1,}\\.?\\d{0,}\\s\\w{1,}),\\s{1,}\\d{1,}\\s{1,}\\w{1,}");
QRegExp rxDigit("\\d");
if (srcOrDst == "src"){
ui->label_serial_monitor_src->setText(ui->pushButton_serial_info->text());
//isso já é garantido fora, mas se houver uma mudança no código, isso pode passar despercebido, então, melhor proteger
if (ui->comboBox_Source_bitwise->currentIndex() >0 && !ui->comboBox_Source_bitwise->currentText().isEmpty()){
dev = "/dev/"+ui->comboBox_Source_bitwise->currentText();
devRaw = dev.remove(rxDigit);
params << "-l" << devRaw;
diskSize.start("fdisk",params);
if (diskSize.waitForFinished()){
result = diskSize.readAllStandardOutput();
diskSize.close();
}
else{
log(tr("[warning] monitor settings src: processo não pronto para leitura (disk size) - ").toUtf8());
return;
}
rx.indexIn(result);
QString srcSize = rx.capturedTexts().last();
ui->label_pbar_mon_src->setText(srcSize);
ui->label_size_src->setText(srcSize);
}
return;
}
ui->label_serial_monitor_dst->setText(ui->pushButton_serial2_info->text());
if (ui->comboBox_Target_bitwise->currentIndex() >0 && !ui->comboBox_Target_bitwise->currentText().isEmpty()){
dev = "/dev/"+ui->comboBox_Target_bitwise->currentText();
devRaw = dev.remove(rxDigit);
params << "-l" << devRaw;
diskSize.start("fdisk",params);
if (diskSize.waitForFinished()){
result = diskSize.readAllStandardOutput();
diskSize.close();
}
else{
log(tr("[warning] monitor settings dst: processo não pronto para leitura - ").toUtf8());
return;
}
rx.indexIn(result);
QString dstSize = rx.capturedTexts().last();
ui->label_pbar_mon_dst->setText(dstSize);
ui->label_size_dst->setText(dstSize);
QRegExp rxDigit("\\d");
if (!ui->label_size_src->text().contains(rxDigit) || !ui->label_size_dst->text().contains(rxDigit)){
return;
}
float src,dst;
src = ui->label_size_src->text().split(" ").at(0).toFloat();
dst = ui->label_size_dst->text().split(" ").at(0).toFloat();
if (ui->label_size_src->text().contains("TB")){
src = (src*1000)*1000;
}
else if (ui->label_size_src->text().contains("GB")){
src = src*1000;
}
if (ui->label_size_dst->text().contains("TB",Qt::CaseInsensitive)){
dst = (dst*1000)*1000;
}
else if (ui->label_size_dst->text().contains("GB",Qt::CaseInsensitive)){
dst = dst*1000;
}
if (src > dst){
ui->comboBox_bitwiseTools->setDisabled(true);
QMessageBox msgSize;
msgSize.setStyleSheet("QMessageBox{border: 2px solid; border-color: rgb(85, 170, 255);}");
msgSize.setWindowTitle(tr("Destino menor que Origem"));
msgSize.setText(tr("A mídia de Destino é menor que a mídia de Origem. Não será possível gerar a imagem."));
msgSize.exec();
log(tr("[user] Midia de destino menor que disco de origem: ").toUtf8());
return;
}
if (src == dst && !ui->radioButton_bw_disc2disc->isChecked()){
ui->comboBox_bitwiseTools->setDisabled(true);
QMessageBox msgSize;
msgSize.setStyleSheet("QMessageBox{border: 2px solid; border-color: rgb(85, 170, 255);}");
msgSize.setWindowTitle(tr("Destino igual Origem"));
msgSize.setText(tr("A mídia de Destino é do mesmo tamanho da Origem. Somente Origem a Destino é possível."));
msgSize.setDetailedText(tr("No menu Geração de Imagem a opção Origem a Destino deve ser marcada. Ainda assim\
há um pequeno mas possível risco de não-alocação dos dados."));
msgSize.exec();
log(tr("[user] Midias do mesmo tamanho: ").toUtf8());
return;
}
}
}
QString MainWindow::mountCommandToEWFthread(QString fileNameSelected)
{
//ewfacquire /dev/sdb -t DESTINO -b ReadAtOnce -B BytesToAcquire -c CompressionMethod -C CaseNumber -d HashType -D Description -e ExaminerName -E EvidenceNumber -f UseEWFfileFormat -g Granularity -l FileNameHash -m MediaType -M MediaCharacteristics -N Notes -o StartAtOffset -P BytesPerSector -r RetriesOnError -S EvidenceSegment (-w) -u
// src fullPathAndFileName -b 64 -B 4126146560 -c deflate:none -C 01 -d sha1 -D 'Description_aaa' -e 'Djames_Suhanko' -E 001 -f encase6 -g 64 -l FileNameHash -m removable -M logical -N 'Notes_aaa' -o 0 -P 512 -r 2 -S 1048576000 -u
QString fileName = fileNameSelected.replace(" ","_");
QString command;
QString hash;
command = "/dev/"+ui->comboBox_Source_bitwise->currentText() + " ";
command += "-t "+this->common->TARGET_DIR+"/"+fileName+" ";
command += "-b "+ui->label_readOnce->text().split(" ").at(0)+" ";
command += "-B "+ui->lineEdit_limit->text()+" ";
command += "-c "+ui->comboBox_compressMethod->currentText()+":"+ui->comboBox_compressLevel->currentText()+" ";
QString caseNumber = ui->label_caseNumberInfo->text();
if (!caseNumber.contains(QRegExp("\\d"))){
caseNumber = "00";
}
command += "-C "+caseNumber+" ";
if (ui->checkBox_hash->isChecked()){
if (ui->radio_sha->isChecked()){
if (!ui->comboBox_hash->currentText().contains("sha1") && !ui->comboBox_hash->currentText().contains("sha256")){
hash = "sha256";
}
else{
hash = ui->comboBox_hash->currentText();
}
command += "-d "+hash+" ";
}
}
QString description = ui->label_description->text();
if (description.isEmpty() || description.length() < 2){
description = tr("Nulo");
}
else{
description = description.replace(" ","_");
}
command += "-D "+description+" ";
QString examiner;
if (ui->label_examinerInfo->text().isEmpty()){
examiner = tr("Não_Informado");
}
else{
examiner = ui->label_examinerInfo->text().replace(" ","_");
}
command += "-e "+examiner+" ";
QString evidenceNumber = ui->label_evidenceInfo->text();
if (evidenceNumber.isEmpty() || !evidenceNumber.contains(QRegExp("\\d"))){
evidenceNumber = "00";
}
command += "-E "+evidenceNumber+" ";
command += "-f "+ui->comboBox_ewfType->currentText()+" ";
command += "-g "+ui->label_granularity->text().split(" ").at(0)+" ";
command += "-l /var/log/ewf/DWatson_EWF-"+this->dateTimeNowString().replace(" ","_")+".log ";
command += "-m "+ui->comboBox_midia->currentText()+" ";
command += "-M "+ui->comboBox_charact->currentText()+" ";
QString notes = ui->label_notes->text();
if (notes.isEmpty() || notes.length() < 2){
notes = tr("Sem_anotações");
}
else{
notes = notes.replace(" ","_");
}
command += "-N "+notes+" ";
command += "-o "+ui->lineEdit_offset->text()+" ";
command += "-P "+ui->label_bytesPerSector->text().split(" ").at(0)+" ";
command += "-r "+ui->label_RetriesOnError->text().split(" ").at(0)+" ";
command += "-S "+ui->label_imgSplitVal->text().split(" ").at(0)+"000 ";
if (ui->checkBox_WipeSectorOnError->isChecked()){
command += "-w ";
}
command += "-u";
return command;
}
void MainWindow::parseValueToGraph(QString strVal, QString toolUsed)
{
float value = 0;
float result = 0;
if (toolUsed == "dcfldd"){
if (strVal.contains(QRegExp("\\d"))){
value = strVal.toFloat();
result = value - this->lastVal;
this->lastVal = value;
}
}
else if (toolUsed == "wipe"){
if (strVal.contains(QRegExp("\\d"))){
result = strVal.toInt();
this->graph->itemName->setText(ui->label_status->text());
}
}
else if (toolUsed == "dc3dd" || toolUsed == "dd"){
value = strVal.toFloat();
result = value - this->lastVal;
this->lastVal = value;
}
int tamanho_janela = 120;
if (j > tamanho_janela) {
this->graph->setValuesX(j-tamanho_janela, j);
}
//abaixo, reajusta o tamanho da matriz se o valor for maior que Y ----//
if (result > limit){
limit = result+1;
this->graph->setValuesY(0, limit);
}
//acima, reajusta o tamanho da matriz se o valor for maior que Y ----//
this->graph->addNewValue(j, result);
j++;
}
void MainWindow::preserveOnReload()
{
//Monta o combobox das ferramentas
QStringList bitWiseToolsList;
bitWiseToolsList << tr("Escolha ferramenta de cópia") << tr("DD - Tradicional Disc Dump (dd)") << tr("DCFLDD - Disc Dump Forense (dcfldd)") << tr("DC3DD - Disc Dump Forense (dc3dd)") << tr("EWF - Aquisição para ler no EnCase(c)");
ui->comboBox_bitwiseTools->clear();
ui->comboBox_bitwiseTools->addItems(bitWiseToolsList);
//outros
QString d,h;
d = ui->label_date->text();
h = ui->label_hour->text();
QString bkp = ui->label_executing_tasks->text();
ui->label_executing_tasks->setText(bkp);
ui->groupBox_language->setDisabled(true);
ui->pushButton_datetime->setEnabled(true);
ui->checkBox_gerarLog->setEnabled(true);
ui->textEdit->setText(tr("Olá. Lembrarei sempre que para iniciar as operações, você deve selecionar um idioma, confirmar ou ajustar data e hora e confirmar em 'Ok'."));
ui->label_date->setText(tr(d.toUtf8()));
ui->label_hour->setText(tr(h.toUtf8()));
}
void MainWindow::resetGraph()
{
this->graph->clear();
this->graph->setValuesY(0, 10);
this->lastVal = 0;
this->j = 0;
}
void MainWindow::resetParams()
{
ui->comboBox_Source_bitwise->setCurrentIndex(0);
ui->comboBox_Target_bitwise->setCurrentIndex(0);
enableFooterWidgets(false);
ui->checkBox_wipe->setChecked(false);
ui->progressBar->setValue(0);
ui->progressBar->setDisabled(true);
ui->pushButton_colect->setEnabled(false);
ui->stackedWidget->setCurrentIndex(0);
ui->stackedWidget->setVisible(false);
}
void MainWindow::screenshotRename()
{
if (ui->checkBox_rename_shots_wayland->isChecked()){
if (!this->autoRenameShot->isRunning()){
this->autoRenameShot->start();
ui->label_executing_tasks->setText(ui->label_executing_tasks->text()+"renameShot ");
}
return;
}
this->autoRenameShot->terminate();
}
void MainWindow::screenShort()
{
QDateTime now = QDateTime::currentDateTime();
QString FileName = now.toString().replace(" ","_");
this->screenshot->shootScreen(FileName,true);
}
void MainWindow::screenShotSelfShot()
{
this->screenshot->shootScreen("screenshot-checkbox-"+dateTimeNowString().replace(" ","_").toUtf8(),true);
}
//TODO: testar no live e ver se aplicou
void MainWindow::setDeviceToReadOnly(QString device, bool setRO)
{
QMessageBox msg;
msg.setStyleSheet("QMessageBox{border: 2px solid; border-color: rgb(85, 170, 255);}");
if (device.contains("Dev")){
msg.setText(tr("Dispositivo não selecionado"));
msg.setWindowTitle(tr(" A T E N Ç Ã O "));
msg.exec();
log("[user] dispositivo não selecionado para somente-leitura");
return;
}
if (device.contains("/")){
msg.setText(tr("O dispositivo não deve ter caminho precedente em setDeviceToReadOnly"));
msg.setWindowTitle(tr(" ERRO DO PROGRAMA "));
log(tr("[warning] ERRO DO PROGRAMA ").toUtf8());
msg.exec();
return;
}
if (!QFile::exists("/dev/"+device)){
msg.setText(tr("Impossível abrir dispositivo"));
msg.setWindowTitle(tr(" A T E N Ç Ã O "));
msg.exec();
log(tr("[warning] Dispositivo aparece na lista, mas não há permissões de acesso: ").toUtf8());
return;
}
QProcess setROorRW;
QStringList params;
if (setRO){
params << "--setro";
log(tr("[user] Dispositivo marcado para somente-leitura:").toUtf8());
}
else{
params << "--setrw";
log(tr("[user] Dispositivo marcado para leitura-escrita").toUtf8());
}
//o blockdev bloqueia por partição e dispositivo, então melhor aplicar em tudo, protegendo inclusive a MBR ou GPT.
params << "/dev/"+device.left(3)+"*";
QString comm = "blockdev";
if (QFile::exists("/home/djames/DEVEL")){
comm = "ls";
}
setROorRW.start(comm,params);
if (!setROorRW.waitForFinished()){
msg.setText(tr("Não foi possível aplicar a operação solicitada!"));
msg.setWindowTitle(tr(" A T E N Ç Ã O "));
log(tr("[warning] Não foi possive aplicar o modo solicitado:").toUtf8());
msg.exec();
return;
}
//Checando se o dispositivo foi migrado para a opção selecionada
QString rawDevice = device.left(3);
if (!QFile::exists("/sys/block/"+rawDevice+"/ro")){
QRegExp rxRaw("(sd\\w)");
if (device.contains(rxRaw)){
rxRaw.indexIn(device);
QString rawDevice = rxRaw.capturedTexts().last();
}
if (!QFile::exists("/sys/block/"+rawDevice+"/ro")){
QMessageBox msg;
msg.setStyleSheet("QMessageBox{border: 2px solid; border-color: rgb(85, 170, 255);}");
QString rwRo = tr(" leitura e escrita.");
if (ui->checkBox_readOnly_bw->isChecked()){
rwRo = tr(" proteção contra escrita.");
}
msg.setText(tr("Não foi possível verificar se o dispositivo foi migrado para")+tr(rwRo.toUtf8()));
msg.setWindowTitle(tr("Leitura e escrita ou somente leitura"));
log(tr("[warning] Não foi possivel verificar se o dispositivo foi migrado para").toUtf8() + tr(rwRo.toUtf8()).toUtf8());
msg.exec();
return;
}
}
QFile systemFileToSeeIfIsReadOnlyOrReadAndWrite("/sys/block/"+rawDevice+"/ro");
if (!systemFileToSeeIfIsReadOnlyOrReadAndWrite.open(QIODevice::ReadOnly | QIODevice::Text)){
msg.setText(tr("Não foi possível confirmar se o dispositivo está em modo somente-leitura."));
msg.setDetailedText(tr("Não foi possível verificar se a mídia está em modo 'somente leitura' ou 'leitura e escrita'.\
Não há problema aparente, mas não há garantia de proteção da origem caso se\
tente gravar nela."));
msg.setWindowTitle(tr(" A T E N Ç Ã O "));
log(tr("[warning] Não foi verificado o modo de operação da origem.").toUtf8());
msg.exec();
return;
}
QByteArray line;
line = systemFileToSeeIfIsReadOnlyOrReadAndWrite.readLine();
if (line.isEmpty()){
msg.setText(tr("Não foi possível confirmar se o dispositivo está em modo somente-leitura."));
msg.setDetailedText(tr("Não foi possível verificar o identificado de modo de operação do sistema.\
Não há problema aparente, mas não há garantia de proteção da origem caso se\
tente gravar nela."));
msg.setWindowTitle(tr(" A T E N Ç Ã O "));
log(tr("[warning] Não foi verificado o modo de operação da origem.").toUtf8());
msg.exec();
return;
}
systemFileToSeeIfIsReadOnlyOrReadAndWrite.close();
if (QString(line).contains("1") && setRO){
return;
}
else if (QString(line).contains("0") && !setRO){
return;
}
else{
QString rwOrRo = tr(" SOMENTE LEITURA ");
if (!setRO){
rwOrRo = tr(" LEITURA E ESCRITA ");
}
msg.setText(tr("Operação não efetuada. Você selecionou")+rwOrRo+tr("porém não foi possível executar a operação no dispositivo"));
msg.setDetailedText(tr("Isso significa que o modo de proteção ou desproteção não foi realizado.\
Não há problema aparente, exceto a midia esteja protegida e você deseje gravar nela."));
msg.setWindowTitle(tr(" A T E N Ç Ã O "));
msg.exec();
}
}
void MainWindow::Settings(){
QString iniFile = "/home/djames/dwatson.ini";
QSettings settings(iniFile,QSettings::IniFormat);
QString nome = settings.value("wayland.general/nome","dwos").toString();
this->graph->setVisible(true);
QString itemName = settings.value("dwatson.graph/itemName","Djames Watson I/O").toString();
this->graph->itemName->setText(itemName);
this->graph->setMarginConfig(5,15,25,15);
this->graph->setMinimumHeight(200);
this->graph->setMinimumWidth(100);
// init values
QString graphX,graphY;
graphX = settings.value("dwatson.graph/setTimeSampleInMinutes","2").toString();
graphY = settings.value("dwatson.graph/setValuesY","0,10").toString();
//TODO: ver o qunto a matriz suporta e limitar o tempo pro cara não colocar 4 semanas de amostragem
this->graph->setValuesX(0,graphX.toInt()*60);
this->graph->setValuesY(graphY.split(",").at(0).toInt(),graphY.split(",").at(1).toInt());
ui->verticalLayout_9->addWidget(graph);
this->graph->itemName->move(40,5);
QString dir = settings.value("dwatson.general/fonts","/usr/share/fonts/truetype/droid/").toString();
QDir directory(dir);
QStringList entries = directory.entryList();
for (int i=2;i<entries.length();i++){
QFontDatabase::addApplicationFont("/usr/share/fonts/truetype/droid/"+entries.at(i));
}
bool maximizing = settings.value("dwatson.general/windowMaximized","false").toBool();
if (maximizing){
int delay = settings.value("dwatson.general/maximizedDelay","2").toInt();
delay = delay * 1000;
QTimer::singleShot(delay, this, SLOT(showMaximized()));
}
ui->checkBox_gerarLog->setEnabled(settings.value("dwatson.general/makeLog","false").toBool());
ui->checkBox_gerarLog->setChecked(settings.value("dwatson.general/makeLog","false").toBool());
this->lang = settings.value("dwatson.general/lang","none").toString();
if (!this->lang.contains("none")){
QTimer::singleShot(1000,this,SLOT(slotLangFromIniFile()));
}
//intervalo do shot
this->shotInterval = settings.value("dwatson.general/shotInterval","1500").toInt();
this->toolTips();
//cast convertion
ui->label_conversion_cast_value->setText(tr("Não iniciado"));
}
void MainWindow::setRadioTextTo(QString srcOrDst, QString value)
{
ui->pushButton_show_data->setEnabled(true);
if (srcOrDst == "src"){
ui->radioButton_show_src_data->setText(value);
ui->radioButton_show_src_data->setEnabled(true);
return;
}
ui->radioButton_show_dst_data->setText(value);
ui->radioButton_show_dst_data->setEnabled(true);
}
void MainWindow::slotCastConvFinished(QString msg)
{
ui->label_conversion_cast_value->setText(msg);
if (msg.contains(tr("Finalizado")) && ui->checkBox_remove_wcap->isChecked()){
QString path = this->screencast->getWcapFullPath();
if (path.isEmpty()){
return;
}
QFile wcap(path);
wcap.remove();
}
}
void MainWindow::SlotChangeStackTabFirst()
{
ui->stackedWidget->setCurrentIndex(0);
}
void MainWindow::SlotChangeStackTabMiddle()
{
ui->stackedWidget->setCurrentIndex(1);
}
void MainWindow::SlotChangeStackTabNext()
{
ui->stackedWidget->setCurrentIndex(2);
}
void MainWindow::slotChangeTabWidget(int pos)
{
if (pos != IMGTBOX){
return;
}
log(tr("[user] Operando na janela de imagem: ").toUtf8());
//limpa os labels se não tiver uma thread em execução (exceto a systeminfo, que apenas coleta dados para monitoramento)
ui->tabWidget->setCurrentIndex(IMGTAB);
if (!gpt->isRunning() && !wiper->isRunning() && !bitwise->isRunning() && !fingerprint->isRunning() && !crypt->isRunning() && !ewfAcquiring->isRunning()){
ui->pushButton_model2_info->setText("");
ui->pushButton_model_info->setText("");
ui->pushButton_serial2_info->setText("");
ui->pushButton_serial_info->setText("");
}
//Monta o combobox das ferramentas
QStringList bitWiseToolsList;
bitWiseToolsList << tr("Escolha ferramenta de cópia") << tr("DD - Tradicional Disc Dump (dd)") << tr("DCFLDD - Disc Dump Forense (dcfldd)") << tr("DC3DD - Disc Dump Forense (dc3dd)") << tr("EWF - Aquisição para ler no EnCase(c)");
ui->comboBox_bitwiseTools->clear();
ui->comboBox_bitwiseTools->addItems(bitWiseToolsList);
}
void MainWindow::slotChangeToolBoxTab(int pos)
{
//wipe só é permitido na aba de geração de imagem, onde os dispositivos podem ser manipulados
//mudança da tab deve reajustar o texto do label de status
if (pos != IMGTAB){
ui->checkBox_wipe->setChecked(false);
ui->checkBox_wipe->setDisabled(true);
}
//abre o menu de opções do toolbox relacionado à geração de imagens
if (pos == IMGTAB){
ui->toolBox->setCurrentIndex(IMGTBOX);
ui->label_status->setStyleSheet("color:black;");
}
//isso protege de uma segunda operação
if (gpt->isRunning() || wiper->isRunning() || bitwise->isRunning() || fingerprint->isRunning() || ewfAcquiring->isRunning() || crypt->isRunning()){
log("[step] Bloqueio dos componetes de geração de imagem durante a execução de um processo ");
ui->comboBox_Source_bitwise->setDisabled(true);
ui->comboBox_Target_bitwise->setDisabled(true);
ui->comboBox_target_format->setDisabled(true);
ui->comboBox_bitwiseTools->setDisabled(true);
ui->label_status->setStyleSheet("color:black;");
return;
}
ui->comboBox_Source_bitwise->clear();
ui->comboBox_target_format->clear();
ui->comboBox_Source_bitwise->setEnabled(true);
ui->comboBox_Source_bitwise->addItems(this->common->connectedDevices(true,"none"));
this->comboBoxFS();
this->enableFooterWidgets(false);
ui->pushButton_model2_info->setText("");
ui->pushButton_model_info->setText("");
ui->pushButton_serial2_info->setText("");
ui->pushButton_serial_info->setText("");
ui->pushButton_model2_info->setDisabled(true);
ui->pushButton_model_info->setDisabled(true);
ui->pushButton_serial2_info->setDisabled(true);
ui->pushButton_serial_info->setDisabled(true);
ui->label_size_dst->clear();
ui->label_size_src->clear();
ui->label_status->setText(tr("Nenhum processo em execução no momento."));
//Valida tamanho do destino
if (pos == TABMON){
QRegExp rx("\\d");
if (!ui->label_pbar_mon_dst->text().contains(rx)){
return;
}
rx.setPattern("(\\s\\w{1,})");
QString src_compare,dst_compare;
rx.indexIn(ui->label_pbar_mon_dst->text());
dst_compare = rx.capturedTexts().last();
rx.indexIn(ui->label_pbar_mon_src->text());
src_compare = rx.capturedTexts().last();
if (!src_compare.isEmpty() && src_compare == dst_compare){
rx.setPattern("(\\d{1,}\\.?\\d?).*");
int src_size,dst_size;
rx.indexIn(ui->label_pbar_mon_src->text());
src_size = rx.capturedTexts().last().toFloat();
if (src_size > 0){
rx.indexIn(ui->label_pbar_mon_dst->text());
dst_size = rx.capturedTexts().last().toFloat();
if (dst_size < src_size){
log("[warning] 826 MW: Destino menor que Origem ");
}
}
}
}
}
void MainWindow::shotWindowOnly(QString name)
{
this->grab().save("/var/log/screenshots/"+name+".png","png");
emit nameFromShot(name);
}
void MainWindow::slotSliderBytesPerSector(int val)
{
ui->label_bytesPerSector->setText(QString::number(val)+" (Bytes)");
}
void MainWindow::slotSliderDataBlock(int val)
{
int result = 1;
for (int i=1;i<val;i++){
result = result * 2;
}
result = result < ui->horizontalSlider_gran->value() ? ui->horizontalSlider_gran->value() : result;
ui->label_readOnce->setText(tr(QString::number(result).toUtf8())+tr(" (setores)"));
}
void MainWindow::slotSliderEvidenceSegment(int val)
{
ui->label_imgSplitVal->setText(QString::number(val)+" (MB)");
}
void MainWindow::slotSliderGran(int val)
{
ui->label_granularity->setText(QString::number(val)+tr(" (setores)"));
}
void MainWindow::slotSliderRetriesOnError(int val)
{
ui->label_RetriesOnError->setText(QString::number(val)+tr(" (vezes)"));
}
void MainWindow::slotAllDevsAndPartsToImgRead()
{
QStringList feed = this->common->connectedDevices(false,"none");
for (int i=1;i<feed.length();i++){
if (!feed.at(i).contains(QRegExp("\\d"))){
feed.removeAt(i);
}
}
ui->comboBox_srcImgToRead->addItems(feed);
}
void MainWindow::slotButtonMsg(QString CancelColect)
{
ui->pushButton_colect->setText(CancelColect);
if (CancelColect.contains("Cancel")){
ui->pushButton_colect->setEnabled(true);
}
else{
ui->pushButton_colect->setEnabled(false);
}
}
void MainWindow::cancelAllRunningProcess()
{
if (this->gpt->isRunning()){
this->gpt->exit(); //TODO: incluir terminate, signal e exit dentro - incluir outras threads
}
if (this->wiper->isRunning()){
emit signalTerminateWipe();
}
if (this->bitwise->isRunning()){
emit signalStopBitWiseCopyNow();
}
if (this->ewfAcquiring->isRunning()){
emit signalStopEWFprocess();
}
if (this->crypt->isRunning()){
emit signalStopCrypt();
}
}
void MainWindow::colectHashInfo(int tab)
{
//se mudar de aba sem iniciar o processo, os widgets se reiniciam, portanto é seguro essa validação abaixo
if (tab == IMGTAB){
//se nao estiverem vazios, as midias ja foram selecionadas
if ((!ui->pushButton_serial_info->text().isEmpty() && !ui->pushButton_serial2_info->text().isEmpty())){
bool inputStatus;
QString text = QInputDialog::getText(this,tr("Digite um nome para o arquivo"),tr("Nome para a Imagem:"),QLineEdit::Normal,
ui->pushButton_model_info->text()+"_"+ui->pushButton_serial_info->text(),&inputStatus);
if (!inputStatus || text.isEmpty()){
QMessageBox box;
box.setStyleSheet("QMessageBox{border: 2px solid; border-color: rgb(85, 170, 255);}");
box.setText(tr("Não é possível iniciar a cópia se houver cancelamento ou nome de arquivo vazio."));
box.setWindowTitle(tr("Cópia não iniciada"));
box.exec();
return;
}
this->files << text;
}
else{
QMessageBox box;
box.setStyleSheet("QMessageBox{border: 2px solid; border-color: rgb(85, 170, 255);}");
QString srcOrdst;
if (ui->pushButton_serial_info->text().isEmpty()){
srcOrdst = tr("origem");
}
else{
srcOrdst = tr("destino");
}
box.setText(tr("Midia de ")+srcOrdst.toUpper()+tr(" não informada?"));
box.setWindowTitle(tr("Midia não informada"));
box.setDetailedText(tr("O campo de serial da mídia de ")+srcOrdst.toUpper()+tr(" não apresenta informações."));
box.exec();
log(tr("[warning] Serial de ").toUtf8()+srcOrdst.toUpper().toUtf8()+tr(" não foi exibido na janela de cópia bitwise: ").toUtf8());
return;
}
}
if (this->files.isEmpty()){
QMessageBox box;
box.setStyleSheet("QMessageBox{border: 2px solid; border-color: rgb(85, 170, 255);}");
box.setText(tr("Melhor selecionar uma imagem primeiro..."));
box.exec();
log(tr("[user] Imagem não selecionada - aba 0 (MW SCHI (95) 614): ").toUtf8());
return;
}
if (ui->checkBoxHashEmArquivo->isChecked() && !ui->checkBox_hash->isChecked()){
QMessageBox box;
box.setStyleSheet("QMessageBox{border: 2px solid; border-color: rgb(85, 170, 255);}");
box.setText(tr("Marque a opção 'Gerar hash' e escolha um tipo primeiro."));
box.exec();
this->log(tr("[user] Faltou selecionar o tipo de hash: ").toUtf8());
return;
}
QStringList hashParams;
QString hash = "hash=";
QString strSha;
QString logName = "hashlog=";
if (ui->checkBox_hash->isChecked()){
ui->pushButton_colect->setText(tr("Aguarde"));//TODO: Verificar se deve ser removido ou trocado para Cancel, caso nao seja Cancel automaticamente
ui->pushButton_colect->setDisabled(true);
if (ui->radio_md5->isChecked()){
strSha = "Md5";
hash += "Md5";
log(tr("[step] Hash:md5 - ").toUtf8());
}
else if (ui->radio_sha->isChecked()){
strSha = ui->comboBox_hash->currentText();
hash += strSha;
log("[step] Hash:" + hash.toUtf8() + " - ");
}
logName += this->files.at(0).split(".").at(0) + "." + strSha;
hashParams << hash << logName << this->files.at(0);