Saltar captcha al autenticar en portal CFDI del SAT

En días recientes, el SAT realizó cambios en su portal CFDI para solicitar se resuelva un captcha al de autenticarse, lo cual causó problemas con varios servicios de descarga masiva de CFDIs. Uno de estos servicios es uno que desarrollamos hace algunos años con CSFacturación, así que hubo que buscar la manera de resolverlo.

Hay varias maneras para solucionar el problema:

  1. Generar un token de autenticación utilizando la llave privada de la FIEL del contribuyente (de la misma manera que lo hace el applet de java que utiliza el SAT en su portal).
  2. Utilizar un servicio externo de resolución de captchas como Anti Captcha.
  3. Utilizar un algoritmo propio con un OCR.
  4. Saltar el captcha completamente.

La opción 1) la exploré y hubo buenos resultados, pero requería el uso de la FIEL. La opción 2) es la que utilizamos para salir del problema inicialmente y aún está soportada para casos futuros. La opción 3) es algo más compleja y propensa a errores, hice un par de pruebas pero no hubo muy buenos resultados. La opción 4) es la que voy a explicar.

Después de investigar un poco, el SAT utiliza un servicio de autenticación provisto por NetIQ. Al entrar directamente a la URL del portal CFDI del SAT se utiliza un método de autenticación (SATUPCFDiCon) que requiere se resuelva un captcha, pero existe un método adicional que se manifiesta en ocasiones, por errores del portal del SAT. Este método (mat-ptsc-totp) no requiere un captcha, ejecutando las peticiones correctas es posible autenticarse y ejecutar peticiones autenticadas al portal del SAT sin resolver captchas. Este método parece ser temporal, sería muy bueno que el SAT incluyera opciones como OAuth para autenticarse de manera segura, pero seguramente eso no sucederá y terminaremos utilizando las opciones 1) o 2) en el futuro. Mientras tanto:

El recurso de autenticación es el mismo de antes: https://cfdiau.sat.gob.mx/nidp/app/login

Pero ahora cambia el atributo id, el método que requiere captcha tiene id 'SATUPCFDiCon', el nuevo método que utilizaremos tiene id 'mat-ptsc-totp'. Los demás atributos quedan igual. La URL final quedaría: https://cfdiau.sat.gob.mx/nidp/app/login?id=mat-ptsc-totp&sid=0&option=credential. Los datos a enviar en el payload del POST a realizar deben ser los mismos que se utilizan para el id 'SATUPCFDiCon', con la excepción del captcha.

Ejemplo de la petición con cURL:

curl "https://cfdiau.sat.gob.mx/nidp/app/login?id=mat-ptsc-totp&sid=0&option=credential" \ 
  -H 'Accept: text/html' \
  -c cookies.txt \
  -d 'option=credential&Ecom_User_ID=RFC&Ecom_Password=PASS&submit=Enviar'

Donde:

-c cookies.txt: Esta opción indica un archivo donde almacenar las cookies que devuelva el servidor en la respuesta.
-d 'option=credential&Ecom_User_ID=RFC&Ecom_Password=PASS&submit=Enviar': El payload a enviar con la petición, cambiar los valores para 'Ecom_User_ID' y 'Ecom_Password' al RFC y CIEC, respectivamente, del contribuyente que se quiera autenticar.

Después de realizar la petición a través de POST, si se han establecido correctamente las credenciales de acceso, se podrá continuar con el flujo normal para completar la autenticación (como se hacía anteriormente).

Puedes comprobar que la autenticación ha sido exitosa, ejecutando la siguiente petición GET:

curl 'https://cfdiau.sat.gob.mx/nidp/jsp/content.jsp?sid=0' \
  -H 'Accept: text/html' \
  -b cookies.txt \
  -c cookies.txt

En el HTML de la respuesta debe haber este mensaje: Your session has been authenticated and is valid for 10 minutes.

Este método ha disminuido también los errores en la autenticación que se producen aleatoriamente al autenticarse utilizando el método SATUPCFDICon, incluso es más eficiente ya que requiere menos peticiones para comenzar la autenticación, puede iniciarse directamente con esta petición, a diferencia del método SATUPCFDICon que requiere realizar peticiones específicas para comenzar el proceso de autenticación.

Posted by:

Share:

Posted by Jamesbut on
The detrimental impact sleep apnea has on the lives of countless sufferers is a very serious matter. Fortunately, with a bit of knowledge and research, it is possible for just about anyone to learn effective techniques for managing the condition. Review the ideas below for some useful information about battling sleep apnea successfully.

Try using a mouth guard that's custom-fitted for you. These are made especially for those suffering from sleep apnea. If you don't have CPAP, then this guard is an excellent alternative. Also, it's a lot more comfortable wearing this mouth guard while sleeping. It really helps keep the airways clear and keeps the soft tissues of the throat stable.

If you have just been diagnosed with sleep apnea and prescribed a CPAP, join a CPAP support group. It can be quite difficult to get used to sleeping with a mask on your face every night. Sitting in a room full of other people going through the same thing can be very empowering. You can learn from others who have had the same issues you are having and made adjustments to make it work.

If you have sleep apnea and cannot break the habit of sleeping on your back, try sleeping in a t-shirt with two tennis balls sewn into the back. Making this sleep shirt is a simple project to do at home, and it can help to break you of sleeping on your back. Every time you try to roll over on your back in your sleep, the tennis balls will remind you to roll back onto your side.

Try your best to lay off tobacco and nicotine products. Cigarette smoke can irritate your upper airway causing it to swell up, subsequently hindering your ability to breath during the night. Quitting smoking could therefore, significantly improve your sleep apnea symptoms and will also improve your body's overall health and your feelings of well-being.

If you think that you may have sleep apnea, set up a video of yourself as you sleep. Just be sure that the video recorder has sound capability. When you wake up, look at the video, and if it seems like something other than snoring is going on, it may be time to go to the doctor.

Consider an alternative sleep apnea flower remedy therapy (also known as essence therapy). Vervain is used in this treatment for its calming and relaxing effects. This can help treat your symptoms, including insomnia problems associated with your apnea. As an added bonus, it also helps reduce overall stress and lower high blood pressure.

The most important aspect of dealing with sleep apnea is understanding exactly what it is. Unlike simple snoring, it is when a sleeper stop's breathing for a short period of time while he is sleeping. If your sleep partner tells you that sometimes you stop breathing, there is a good chance you have apnea.

Minimize your risk from the conditions causing sleep apnea. Some sleep apnea risk factors cannot be changed, like genetic or hereditary reasons. But others, such as weight smoking and drinking, can be controlled.

Make no mistake, sleep apnea is one of the most disruptive conditions a person can have, largely due to its ability to rob sufferers of the sound sleep they need to stay healthy. The best way to effectively deal with the condition is to understand it completely. Keep the information in this article handy in order to stay on top of this dangerous condition and reclaim peace of mind.

[url=https://www.viagrasansordonnancefr.com/]viagrasansordonnancefr.com[/url]
Posted by Danielfix on
Save 50% captcha solving cost - Decaptcher.org - Decaptcher.org
[url=http://decaptcher.org/]Save 50% captcha solving cost - Decaptcher.org - Decaptcher.org!..[/url]
Posted by JefferyGetry on
No matter how happy people may be with their life, stress may find its way in. Sometimes stress is so hard to control because people do not know how to go about fixing their stresses. In the following article, you are going to be given advice to help you deal with life's stresses.

viagra prix maroc officiel
Posted by TomaPurge on
Food of fried tomatoes like absolutely everything. Guests usually require guide are surprised mastery chef. Even guys with pleasure eat fried tomato in breadcrumbs. Tomatoes very good combined are combined with many products. Garlic adds sharpness. Cheese gives red crust. Italian spices turn roasted tomatoes into a dish from a restaurant. Omelette with tomatoes - simple and nutritious dish for breakfast. Prepare including sandwiches with fried tomatoes.
Cooking tomatoes simply. For cooking use butter. In olive oil - fewer calories. It is also combined mixed with fried cubes tomatoes.
homemade stewed tomatoes
Posted by Shanjounk on
Kamagra 50mg Side Effects Viagra Online Bestellen Ausland Lasix Generic Drug cialis online Curetage Ou Cytotec Dog Medicine Keflex PiРів„– Cialis Kamagra
Leave a Reply



(Your email will not be publicly displayed.)