Lab 4 Cripto

el coso del cosito

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Lab 4 Cripto
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  el coso del cosito
// @author       Daniel Salas
// @match        *://cripto.tiiny.site/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js#sha512-E8QSvWZ0eCLGk4km3hxSsNmGWbLtSCSUcewDQPQWZF6pEU8GlT8a5fF32wOl1i8ftdMhssTrF/OhyGWwonTcXA==
// ==/UserScript==

//Parte 1
$(document).ready(function() {
    //filtra por Parrafo
    var divElements = $("div.Parrafo");
    var key = "";
    divElements.each(function() {
      divElements.each(function() {
        var paragraph = $(this).text().trim();
        var sentences = paragraph.split(".");
        for (var i = 0; i < sentences.length; i++) {
          var sentence = sentences[i].trim();
          if (sentence !== "") {
            //extrae y agrega los primeros chars
            var firstChar = sentence.charAt(0);
            key += firstChar;
          }
        }
      });
    });

    //imprime la key
    console.log("La llave es: " + key);

     //Parte 2

    //encontrar los elementos con clase "M#"
    var hiddenMessages = jQuery('[ class ^=M]').map( function(){return $( this ).attr("id");}).get();
    console.log("Los mensajes cifrados son: " + hiddenMessages.length)

    // Parte 3
    var decrypted = '';
    var encoded_key = CryptoJS.enc.Utf8.parse(key);

    for(var j = 0; j < hiddenMessages.length; j += 1){
        decrypted = CryptoJS.TripleDES.decrypt(hiddenMessages[j].toString(), encoded_key, {
            mode: CryptoJS.mode.ECB
    });
    console.log(hiddenMessages[j], decrypted.toString(CryptoJS.enc.Utf8))

    //agregar el texto a la pag
    var decryptedText = document.createElement('p');
    decryptedText.style.color = 'red';
    decryptedText.textContent = decrypted.toString(CryptoJS.enc.Utf8);
    var messageDiv = $('div.M'+[j+1]);
    messageDiv.append(decryptedText);
    }
});