Class: Hardsploit_GUI

Inherits:
Object
  • Object
show all
Defined in:
lib/hardsploit.rb

Instance Method Summary collapse

Constructor Details

#initializeHardsploit_GUI

Returns a new instance of Hardsploit_GUI.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hardsploit.rb', line 34

def initialize
  # Launch API
  hardAPI = HardsploitAPI.new(method(:callbackData),method(:callbackInfo),method(:callbackProgress),method(:callbackSpeedOfTransfert))
  $file = nil
  $currentFirmware = nil
  $usbConnected = nil
  $logFilePath = File.expand_path(File.dirname(__FILE__)) + "/logs/error.log"
  $dbFilePath = File.expand_path(File.dirname(__FILE__)) + "/db/hs.db"

  # Launch GUI
  Qt::Application.new(ARGV) do
    $app = self
    w = HardsploitGUI.new(hardAPI)
    centerWindow(w)
    w.show
    exec
  end
end

Instance Method Details

#callbackData(receiveData) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/hardsploit.rb', line 75

def callbackData(receiveData)
  begin
    $file.write(receiveData.pack('C*'))
  rescue
    Qt::MessageBox.new(Qt::MessageBox::Critical, "Critical error", "Error occured when opening the dump file. Consult the logs for more details").exec
  end
end

#callbackInfo(receiveData) ⇒ Object

CALLBACK



56
57
58
# File 'lib/hardsploit.rb', line 56

def callbackInfo(receiveData)
  print receiveData  + "\n"
end

#callbackProgress(percent:, startTime:, endTime:) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/hardsploit.rb', line 60

def callbackProgress(percent:,startTime:,endTime:)
  $pgb.update_value(percent) unless $pgb.nil?
  $app.processEvents
  if percent == 100
    duration = (endTime-startTime).round(2)
    $pgb.display_time("Total duration: #{duration} second(s)")
  end
  #puts "Progress : #{percent}%  Start@ #{startTime}  Stop@ #{endTime}"
  #puts "Elasped time #{(endTime-startTime).round(4)} sec"
end

#callbackSpeedOfTransfert(receiveData) ⇒ Object



71
72
73
# File 'lib/hardsploit.rb', line 71

def callbackSpeedOfTransfert(receiveData)
  puts receiveData
end

#check_ReceivedDataObject



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/hardsploit.rb', line 83

def check_ReceivedData
  result = hardAPI.receiveDATA(2000)
  case result
    when HardsploitAPI::USB_STATE::BUSY
      puts "BUSY"
    when HardsploitAPI::USB_STATE::TIMEOUT_RECEIVE
      puts "TIMEOUT_RECEIVE\n"
    else
      puts "Received"
      p result
  end
end

#check_SendData(value) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/hardsploit.rb', line 96

def check_SendData(value)
  case value
    when HardsploitAPI::USB_STATE::SUCCESSFUL_SEND
      puts "SUCCESSFUL_SEND"
    when HardsploitAPI::USB_STATE::PACKET_IS_TOO_LARGE
      puts "PACKET_IS_TOO_LARGE max: #{USB::USB_TRAME_SIZE}"
    when HardsploitAPI::USB_STATE::ERROR_SEND
      puts "ERROR_SEND\n"
    else
      puts "UNKNOWN SEND STATE"
  end
end