Created
February 13, 2020 02:50
-
-
Save nitrog0d/17fc40a84ccdff758ac54da7f52a9f33 to your computer and use it in GitHub Desktop.
Correios Posta Restante - FiddlerScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a script I made while I worked at Correios (internship for 1 year, first job experience), to speed up one of the most annoying parts of my day there, it's very simple but works perfectly as how I wanted. | |
import System; | |
import Fiddler; | |
class Handlers { | |
static function addCode(oSession: Session, originalCode: String, newCode: String) { | |
oSession.utilReplaceInResponse(originalCode, originalCode + newCode); | |
} | |
// Before Fiddler sends the response | |
static function OnBeforeResponse(oSession: Session) { | |
// All Pages | |
if (oSession.url.Contains('intranetsistemasspi/posta_restante')) { | |
// Tell the script is working | |
oSession.utilReplaceInResponse('<a href="http://sistemasspi/sistemas/stoconsulta/" target="_parent" title="Informações sobre Órgãos">Unidades</a><br>', '<a href="http://sistemasspi/sistemas/stoconsulta/" target="_parent" title="Informações sobre Órgãos">Unidades</a><a href="http://localhost" target="_parent" title="Informações sobre o estado do Script">Script Injetado</a><br>'); | |
} | |
// PR Login page | |
if (oSession.url.Contains('intranetsistemasspi/posta_restante/default.cfm?location=DSP/form_Principal.cfm')) { | |
// Auto Login | |
addCode(oSession, '<input type="reset" value="Limpar" tabindex="4">', '\n<input type="button" value="Agência atual" tabindex="5" onclick="document.frmVerifica.usu_co_mcu.value = \'00000000\'; document.frmVerifica.usu_senha.value = \'00000\'; Preenche();">'); | |
//oSession.utilReplaceInResponse('alert("MCU é campo obrigatório!");', 'document.frmVerifica.usu_co_mcu.value = "00000000"; document.frmVerifica.usu_senha.value = "00000"; document.frmVerifica.submit();'); | |
} | |
// PR Find Objects page | |
if (oSession.url.Contains('intranetsistemasspi/posta_restante/default.cfm?location=OBJETOS/DSP/form_relobj.cfm') || oSession.url.Contains('intranetsistemasspi/posta_restante/default.cfm?location=OBJETOS/DSP/form_relobjdevolvido.cfm')) { | |
// Inject Checkbox to enable/disable the scripts | |
//addCode(oSession, '<form name="frmConObj" method="post">', '\n<input type="checkbox" checked="checked" name="fiddler"> <strong>Habilitar Scripts</strong>'); | |
// Add "Hoje", "Ontem" and "Sexta" buttons | |
addCode(oSession, '<br><input type="button" name = "Relatorio" value="Ver Relatório" onclick="javascript:ChecaCampos()">', '\n<input type="button" name="Relatorio" value="Hoje" onclick="var today = new Date(); var day = today.getDate(); var month = today.getMonth() + 1; var year = today.getYear(); if (day < 10) day = \'0\' + day; if (month < 10) month = \'0\' + month; var input = \'\'; input += day; input += \'/\'; input += month; input += \'/\'; input += year; document.frmConObj.data1.value = input; document.frmConObj.data2.value = input; ChecaCampos();">\n<input type="button" name="Relatorio" value="Ontem" onclick="var today = new Date(); var day = today.getDate() - 1; var month = today.getMonth() + 1; var year = today.getYear(); if (day < 10) day = \'0\' + day; if (month < 10) month = \'0\' + month; var input = \'\'; input += day; input += \'/\'; input += month; input += \'/\'; input += year; document.frmConObj.data1.value = input; document.frmConObj.data2.value = input; ChecaCampos();">\n<input type="button" name="Relatorio" value="Sexta" onclick="var today = new Date(); var day = today.getDate() - 3; var month = today.getMonth() + 1; var year = today.getYear(); if (day < 10) day = \'0\' + day; if (month < 10) month = \'0\' + month; var input = \'\'; input += day; input += \'/\'; input += month; input += \'/\'; input += year; document.frmConObj.data1.value = input; document.frmConObj.data2.value = input; ChecaCampos();">'); | |
//oSession.utilReplaceInResponse('alert(\'Favor Digitar o Período de Chegada!\');', 'if (document.frmConObj.fiddler.checked) { var today = new Date(); var day = today.getDate(); var month = today.getMonth() + 1; var year = today.getYear(); if (day < 10) day = "0" + day; if (month < 10) month = "0" + month; var input = ""; input += day; input += "/"; input += month; input += "/"; input += year; document.frmConObj.data1.value = input; document.frmConObj.data2.value = input; Consultar(); } else { alert(\'Favor Digitar o Período de Chegada!\'); }'); | |
} | |
// PR Insert to DB page | |
if (oSession.url.Contains('intranetsistemasspi/posta_restante/default.cfm?location=OBJETOS/DSP/form_cadobj.cfm')) { | |
// Inject increase number script + Remove the fuckin description script | |
addCode(oSession, 'document.frmConsulta.lpi_nu_item.value = linha + 1;', ' document.frmConsulta.obj_nu_objeto.value = "";'); | |
// Inject copy to clipboard script | |
oSession.utilReplaceInResponse('document.frmConsulta.obj_no_cliente.value = \'\';', 'document.frmConsulta.obj_no_cliente.select(); document.execCommand("copy"); document.frmConsulta.obj_no_cliente.value = "";'); | |
// Inject allow to change item number script | |
oSession.utilReplaceInResponse('onKeyPress="DigitaNum(this)" readonly>', 'onKeyPress="DigitaNum(this)">'); | |
// Inject "Hoje" button | |
addCode(oSession, ' > <font color="Red" size="1"><b>*</b></font>', ' <input type="button" value="Hoje" onclick="var today = new Date(); var day = today.getDate(); var month = today.getMonth() + 1; var year = today.getYear(); if (day < 10) day = \'0\' + day; if (month < 10) month = \'0\' + month; var input = \'\'; input += day; input += \'/\'; input += month; input += \'/\'; input += year; document.frmConsulta.obj_dt_chegada.value = input;">'); | |
// Inject "Simples" and "Registrado" buttons | |
addCode(oSession, ' <font color="Red" size="1"><b>*</b></font>', '<input type="button" value="Simples" onclick="document.frmConsulta.obt_co_objeto_tipo.selectedIndex = 7;"> <input type="button" value="Registrado" onclick="document.frmConsulta.obt_co_objeto_tipo.selectedIndex = 6;"> <input type="button" value="Banco" onclick="document.frmConsulta.obt_co_objeto_tipo.selectedIndex = 8;"> <input type="button" value="PAC" onclick="document.frmConsulta.obt_co_objeto_tipo.selectedIndex = 14;"> <input type="button" value="SEDEX" onclick="document.frmConsulta.obt_co_objeto_tipo.selectedIndex = 15;">'); | |
/* | |
// What a waste of time... You can just click the number in the list... | |
// Inject argument on "exclui" function | |
oSession.utilReplaceInResponse('function exclui(nlinha)', 'function exclui(alt, nlinha)'); | |
// Inject use the argument to check if it's a change or not | |
oSession.utilReplaceInResponse('LimpaItens(nlinha);', 'if (!alt) LimpaItens(nlinha);'); | |
// Inject change to the existent code to make it compatible with the changes | |
oSession.utilReplaceInResponse('<td><a href="JavaScript:exclui(', '<td><a href="JavaScript:exclui(false, '); | |
// Inject "Change" button, so I can modify values without fucking everything | |
oSession.utilReplaceInResponse('<input type="button" value="Inserir" onclick="Insere(100)" name="ins">', '<input type="button" value="Inserir" onclick="Insere(100)" name="ins">\n<input type="button" value="Alterar" onclick="exclui(true, document.frmConsulta.lpi_nu_item.value)">'); | |
*/ | |
// Fix random error that I have never seen in my life? (Actually fixed by enabling "Decode" in Fiddler, /shrug) | |
//oSession.ResponseHeaders.Remove('Transfer-Encoding'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment