Saltar al contenido
Underc0de /foro

Who crashed into you? Hacking License Plates

🌐 This is an automatic translation of a topic from Underc0de, the largest Spanish-speaking hacking and IT community. Read the original (Spanish) and reply →
Muppet ·
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br />
by hdbreaker
<br /><br /><br />Some time ago I had the misfortune of being involved in a somewhat serious traffic accident, where I, for traveling by motorcycle, got the worst part. Totally contrary to what I expected, the person responsible for the accident did not stop to assist me; instead he preferred to flee the scene.<br /><br />After all the medical protocols, a few bruises, and after not finding answers at the police due to lack of witnesses, I decided to begin a personal search to identify the vehicle with the only piece of data I had managed to spot during the crash.<br />
###his license plate number###
<br /><br />For confidentiality reasons I will not use the aggressor's real license plate but one that I happened to read in the vehicle registry while doing the insurance paperwork.<br /><br /><br />The question? <br /><br />Is there a system that would allow me to query the data and the status of a vehicle currently traveling on the street? The answer is yes!<br /><br /><br />After a few queries to google, I managed to find a tax service in the province of Buenos Aires that allows us to query the debt status of a vehicle's license plates.<br /><br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br /><br />It has two ways of working: if you are not the owner you can only obtain the data corresponding to debts on the car, but the system does not allow you to access the sections that identify the person registered in the Vehicle Registry as the title holder of the vehicle.<br /><br /><br />On the other hand, to verify the ownership of the vehicle, the system asks you to enter a special unique verification number that only the owner of the car should possess, since it serves to print payment slips for debts that include the personal data of the vehicle's owner, thereby guaranteeing the privacy of the users' data.<br /><br />
<br />Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br />The first thing we can analyze on the site is that the system's special verifier digit only accepts values ranging from 00 to 99 (the value is not as unique as one believes)<br /><br /><br />Anyway, the license plate to be studied in this entry will be JMO089. After performing some manual tests we can see that the system's captcha is never updated once we are associated with a session, allowing us to manually try all 99 possible combinations until we find the correct one.<br /><br /><br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br /><br />In the image we can see that the captcha does not change as we try possible numeric combinations until we find the correct one, so it gives the possibility of programming a Brute Forcer that keeps trying all possible values until finding the right one. But an attack like that represents a problem by having to face a captcha, something I was not willing to do due to a lack of time to program an Los enlaces son solo para miembros. Registrate o iniciá sesión.<br /><br />The question I asked myself was:<br /><br />What is the way the system validates the correct value of the verifier digit?<br /><br />The first thing I thought was that the system validated the value on the server side after the query, so I started checking the requests the site made when submitting the form. For this I used Live HTTP headers<br /><br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br /><br />Upon finding this, I couldn't believe what I was seeing. Technically speaking, if a validation does not present a web request to the Backend, it means that the validation is being performed on the client side, that is:<br /><br />
THE SYSTEM VALIDATES VIA JAVASCRIPT!
<br /><br />This implies that the validation algorithm of the verifier code is served in some javascript file on the browser side, so I started analyzing the html source of the document to identify some clue about the validation. The first thing I analyzed were the following files:<br /><br /><br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br />Inside the file consultaDatos.js I found the following function with a revealing name: validaDatos<br /><br />
<br />Los enlaces son solo para miembros. Registrate o iniciá sesión
<br />
if (!check.checked && patente.valido(dom1) != true)
<br /><br />In that same function one can see, in the highlighted lines, the structure where the valid license plate message is decided, fulfilling the requirements that the checkbox is checked and that the result of the function patente.valido() is what is needed to correctly resolve the if() decision structure.<br /><br /><br />The problem turned out that the function patente.valido() was not within the same document, so I had to find the file where it was located.<br /><br />For those who don't know how javascript works, I clarify that js files represent a large structured code divided into different files to improve its organization, but as long as these files are included in the html they can make calls to functions defined among them as if they were all members of the same class.<br /><br /><br />After searching a bit, I arrived at the following Los enlaces son solo para miembros. Registrate o iniciá sesión /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br />Inside it we can obtain the structure of the validator code:<br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br />
Complete Function: Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br />After carefully analyzing the code I was able to reveal its final behavior.<br /><br />The code calculates the verifier digit based on the vehicle's license plate, substituting the letters for special numbers to form a decimal string, which it then sums according to its index, evens on one side and odds on the other, as if it were an array.<br /><br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br />Then if these separated values (digi1 and digi2) have a length greater than one digit (0 to 9), it sums them again respectively until obtaining 2 numbers independently with a length of one digit (0 to 9).<br /><br /><br />And then it concatenates them to obtain the magic verifier number:<br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br />What is somewhat comical is that this function has no protection whatsoever, and can be called from the developer console of Google Chrome or Firefox:<br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br />With this verifier number we can perform the query successfully:<br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br />When requesting an invoice we can see the personal data such as the name of the registered title holder and his residential address:<br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión<br />
<br /><br />Doing a bit of reverse engineering I developed the following scripts that allow calculating any verifier digit with just the license plate number:<br />(Soon I will be adding its Python version developed by [Q]3rv[0]):<br /><br />Ruby:<br /><br /><br />
Código: text
<br />require 'colorize' #by hdbreaker<br /><br />class Calculate<br /><br />  def initialize()<br />    #inicializo array asociativo de clase<br />    @letrasValidas ={'A' => '14','B' => '01','C' => '00','D' => '16','E' => '05','F' => '20','G' => '19',<br />                     'H' => '09','I' => '24','J' => '07','K' => '21','L' => '08','M' => '04','N' => '13',<br />                     'O' => '25','P' => '22','Q' => '18','R' => '10','S' => '02','T' => '06','U' => '12',<br />                     'V' => '23','W' => '11','X' => '03','Y' => '15','Z' => '17',' ' => '60',};<br />  end<br /><br />  #Funcion para calcular el numero de patente<br />  def calculate(patente)<br />    patAux = patente.upcase;<br />    pares = 0;<br />    impares = 0;<br /><br />    #Bloque para sustituir las letras por los numeros correspondisntes<br />    @letrasValidas.each { |key|<br />      if(patAux.include? key[0])<br />        patAux = patAux.gsub(key[0], key[1]);<br />      end<br />    }<br /><br />    #Sumo los imares por un lado y los pares por el otro<br />    for x in (0...patAux.length)<br />      if (x % 2 == 0)<br />        pares += patAux[x].to_i;<br />      else<br />        impares += patAux[x].to_i;<br />      end<br />    end<br /><br />    #Si la sumatoria de los pares da un numero mayor a 1 digito, los sumo nuevamente hasta obtener 1 digito<br />    digi1 =pares.to_s;<br />    while (digi1.length > 1)<br />      pares = 0;<br />      for x in (0...digi1.length)<br />        pares += digi1[x].to_i;<br />      end<br />      digi1 = pares.to_s;<br />    end<br /><br />    #Si la sumatoria de los impares da un numero mayor a 1 digito, los sumo nuevamente hasta obtener 1 digito<br />    digi2 =impares.to_s;<br />    while (digi2.length > 1)<br />      impares = 0;<br />      for x in (0...digi2.length)<br />        impares += digi2[x].to_i;<br />      end<br />      digi2 = impares.to_s;<br />    end<br /><br />    ###############Salida en Pantalla###############<br />    puts "\n############## Rentas Ciudad de Buenos Aires ##############".green<br />    puts "URL: ".green+"https://lbserver02.agip.gob.ar/ConsultaPat/index.html".red<br />    puts "Dominio: ".green+patente.red<br />    puts "Verificador: ".green+digi1.red+""+digi2.red<br />    puts "\n"<br />  end<br />end<br /><br />if(ARGV.length==1)<br />  obj = Calculate.new()<br />  obj.calculate(ARGV[0].to_s)<br />else<br />  puts "Usage: ruby calculate.rb [patente]"<br />end<br /><br />
<br /><br />
Los enlaces son solo para miembros. Registrate o iniciá sesión
<br /><br /><br />I hope this entry serves to raise awareness about the security of our personal data, since let's remember that the flaw is in a governmental network that shamelessly exposes people's personal data.<br /><br />And if you are a driver... don't go around the street believing yourself untouchable, you never know who you may cross paths with nor for what they may use your data; perhaps you'll encounter a person who, instead of reporting the flaw, uses your information to find you, go to your house and break your legs.<br /><br />
Regards!
<br /><br />Source: Los enlaces son solo para miembros. Registrate o iniciá sesión
kity54 ·
Interesting contribution, I was looking for something like this and couldn't find it!!
MagoAstral ·
Very interesting, honestly I'll read it when I have time. You are one of the people whose contributions I value most in this community; I especially like that, apart from the presentation, its content is attractive. I take my hat off to you.<br />Regards!
Muppet ·
Cita de: MagoAstral en Febrero 06, 2015, 05:14:45 PM<br />Very interesting, honestly I'll read it when I have time. You are one of the people whose contributions I value most in this community; I especially like that, apart from the presentation, its content is attractive. I take my hat off to you.<br />Regards!<br />
<br /><br />Thank you very much! and thanks to all the readers who value the work of a researcher. It's a pleasure to share information and study new vulnerabilities or simply curiosities when the readers appreciate, share or simply give their opinion about it. I believe a community is for that, so that among all of us we can get a much more objective and professional view of a flaw! I invite you to visit my blog!
Jimeno ·
Oh my, what a botch to do that on the client side... hahahaha. Great idea to automate it, HD!
- ALEAJANDRO - ·
Terrific post! Everything is incredible, from finding the vulnerability, exploiting it, and on top of that automating it!  ;D<br />Without a doubt it was excellent work!
rush ·
Tremendous post!!!! Congratulations, very good contribution. Here in Mexico it's different because to query you need the plate number plus also the last three digits (depending on the city) of the vehicle's circulation card number; these numbers are unique and I don't know in what way a circulation number is calculated, but congratulations, I liked it a lot.
c0n ·
These posts in narrative form are awesome. I wonder what other institutional sites over there have the same implementation...<br /><br />Kudos hdbreaker
erdosain9 ·
This is really good! Buuut it gives me this error<br /><br />/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- colorize (LoadError)<br />   from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'<br />   from funca.rb:1:in `<main>'<br /><br /><br />Any idea???? regards and thank you very much!<br /><br />ps; I removed the first line of the code and then it gives me this error<br />funca.rb:56:in `calculate': undefined method `green' for "\n############## Rentas Ciudad de Buenos Aires ##############":String (NoMethodError)<br />   from funca.rb:66:in `<main>'<br />
Muppet ·
Cita de: erdosain9 en Septiembre 17, 2015, 04:54:22 PM<br />This is really good! Buuut it gives me this error<br /><br />/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- colorize (LoadError)<br />   from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'<br />   from funca.rb:1:in `<main>'<br /><br /><br />Any idea???? regards and thank you very much!<br /><br />ps; I removed the first line of the code and then it gives me this error<br />funca.rb:56:in `calculate': undefined method `green' for "\n############## Rentas Ciudad de Buenos Aires ##############":String (NoMethodError)<br />   from funca.rb:66:in `<main>'<br />
<br /><br />Hey! Sorry for the reply, I don't come around these parts much. The problem you have is because you're missing the colorize gem, try:<br /><br />sudo gem install colorize<br /><br />and when the installation finishes, run the code again. Regards!
Grupo de WhatsApp