Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/14/18 in all areas

  1. Introduction Bitcoin and cryptocurrencies made a lot of noise lately. I have been rather disappointed by the turn the cryptocurrencies took, from an amazing concept to what seems just another way to make quick money ( or not... ). But I became very interested by the technologies enabling cryptocurrencies, and obviously by the concept of a blockchain. The concept is fascinating, and not limited to Bitcoin and friends. We could imagine many applications for such a technology. So, in a proper developer manner, I decided to code one blockchain, or what I think is a blockchain, to understand better what it is. A simple project So, what do we need to create a very simple blockchain? A block A block is what the blockchain is made of. In our case, a block will be composed of a date, an index, some data ( a message in our case ), and the hash of the previous block. Cryptography To keep informations secure, we need to encrypt our data. For our little project, we will use the js-sha256 package. This process will create a string of 64 characters. Ultimately, our blockchain will be a series of hashes, each composed of 64 characters. As I said earlier, we use the hash of the previous block to encrypt a new block ( that is why we call it a chain ). Difficulty and nonce We don't just create one hash per block and that's it. A hash must be valid. In our case, a hash will be valid if the first four characters of our hash are 0. If our hash starts with '0000......', it is considered valid. This is called the difficulty. The higher the difficulty, the longer it takes to get a valid hash. But, if the hash is not valid the first time, something must change in the data we use right? If we use the same data over and over, we will get the same hash over and over and our hash will never be valid. You are right, we use something called nonce in our hash. It is simply a number that we increment each time the hash is not valid. We get our data (date, message, previous hash, index) and a nonce of 1. If the hash we get with these is not valid, we try with a nonce of 2. And we increment the nonce until we get a valid hash. Genesis block Their must be a first block in our chain. It is called the genesis block. Of course, this block can't use the hash of the previous block because it doesn't exist. We will just give it some arbitrary data to create its hash. And that is pretty much what we need for our blockchain. The methods We will need a few methods to make a functional blockchain: initialize our blockchain => creates the genesis block hash our blocks => a function responsible for creating a valid hash check the validity of a hash => does our hash starts with 'OOOO' ? get the last hash => we need the previous hash to create a new block add a new block => We need to do that at one point, if we want a chain THE COOOOODE !! Let's get coding now. For this little project, I will create two files, one called index.js and another called blockchain.js. The second one will hold our little module to create a blockchain. It's straightforward, let's take a look at it: const sha256 = require('js-sha256').sha256 const blockchain = (function(){ const blocks = [] const initBlockchain = () => { const data = 'Hello World!' const timestamp = new Date() const previousHash = 0 const index = 0 hashBlock(data, timestamp, previousHash, index) } const hashBlock = (data, timestamp, prevHash, index) => { let hash = '', nonce = 0 while( !isHashValid(hash) ){ let input = `${data}${timestamp}${prevHash}${index}${nonce}` hash = sha256(input) nonce += 1 } console.log(nonce) blocks.push(hash) } const getLastHash = blocks => blocks.slice(-1)[0] const isHashValid = hash => hash.startsWith('0000') // Difficulty const addNewBlock = data => { const index = blocks.length const previousHash = getLastHash(blocks) hashBlock(data, new Date(), previousHash, index) } const getAllBlocks = () => blocks return { initBlockchain, getLastHash, blocks, getAllBlocks, addNewBlock } })() module.exports = blockchain So, in this module, I have a few methods. At the top, I import the module that will handle the cryptography part. I have an empty array that will hold my blockchain's blocks, called blocks. initBlockchain: This method starts the blockchain by creating the first block, the genesis block. I give it a timestamp, a message, the block's index in the blockchain ( 0 ) and a arbitrary previous hash because there are no previous blocks in the chain yet. With all these informations, I can now create the hash for the genesis block. hashBlock: This method takes all the block's data and creates a hash. As you can see, the first time we run the function for a specific block, the nonce is set to 0. We encrypt our block and check if the hash is valid with isHashValid. In our case, a hash is valid if the four first characters are 0. This is called the difficulty. This is the problem we have to solve to make sure the block can be part of the blockchain. Once the hash is valid, we add it to our blocks array. addNewBlock: This method is responsible for creating a new block. We only need to give it the message as an argument, because all the other arguments ( index, previousHash, and timestamp) can be found in the blockchain. The method calls hashBlock with the data to create and validate the new block. getLastHash: The method I call to get the previous hash. We always need the previous hash to create a new block. getAllBlocks: Just returns all the blocks currently in the blockchain Great, so let's move to index.js to use our new blockchain! const blockchain = require('./blockchain') blockchain.initBlockchain() blockchain.addNewBlock('First new block') blockchain.addNewBlock('I love blockchains') blockchain.addNewBlock('Make me a new hash!!') console.log(blockchain.getAllBlocks()) We initialize our blockchain, then we create three new blocks. When I run this, I get the following chain in response: Initializing the blockchain 139355 30720 68789 51486 [ '0000d87875f12e8c00d60cdfc8c21c4867eb1e732d3bb0e4d60bd0febcfafbaf', '0000331d80f4e83461bad846e082baa08c5e739edfa19a4880c1dcbe4eed1984', '00000dcab247410050e357158edc20555cc0110429023fdadb1d8cda3e06da5e', '0000a16968811cf75c33d877e99f460d396c46b5485f669c8e55b193b862106d' ] The array represent the four blocks. As you can see, every single one of them starts with four zeros, so every single hash is valid. If one of those hashes didn't start with four zeros, I would know right away the hash was invalid, therefore, the data in the corresponding block should probably not be trusted. There are four numbers here: 139355, 30720, 68789, 51486. These are the nonce for each block. I printed them out to see how many times the function hashBlock ran to come to a valid hash. The first block, the genesis block, ran 139355 times before having a valid hash! The second, 30720 times. The third 68789 times and the fourth 51486 times. Conclusion This is a very simple example of a blockchain. I'm pretty sure I missed a few things here. I also kept things pretty simple because hey, I'm learning! This little project made me understand a few things: If one person decides to modify a previous block, she would have to change every single block after that one. Each block inherits from its parent ( previous hash ), so trying to cheat a blockchain seems complicated. But if a majority of the blockchain's users decide to cheat, they could modify a previous block and all agree to change the rest of the blockchain accordingly. A blockchain seems to work only if the majority decides to follow the rules. Or you could end up with two different blockchains, one where the users decided to stick with the original data, and the other where the users decided to use the modified blockchain. I've heard about the Bitcoin enormous use of power where it came to mining. Mining is the concept of solving the difficulty problem when you encrypt the data. You get the transaction and you try to find a valid hash for that block. As a reward for your effort, you get some bitcoin. I can only imagine the amount of power you would use when the blockchain becomes huge. Well, that's about what I got from that. It made things a lot clearer for me. Feel free to correct me if i got things wrong! Sursa: https://dev.to/damcosset/trying-to-understand-blockchain-by-making-one-ce4
    5 points
  2. While this setup of Kali on Windows is not optimal due to various environmental restrictions (such as the lack of raw sockets and lack of customised Kali kernel), there are still many situations where having Kali Linux alongside your Windows 10 machine can be beneficial. One example that comes to mind is consolidation of workspaces, especially if Windows is your main working environment. Other useful situations that crossed our minds were standardizing tools and scripts to run across multiple environments, quick porting of Linux penetration testing command line tools to Windows, etc. For example, below is a screenshot of running the Metasploit Framework from Kali Linux, over WSL. Link: https://www.kali.org/tutorials/kali-on-the-windows-subsystem-for-linux/
    3 points
  3. Name: TheBodyguard.jpg MD5: 1593E87EA6754E3960A43F6592CC2509 import string alfabet = string.ascii_lowercase alfabet2 = string.ascii_uppercase parola = "?" plain_text = "" for i in parola: if i in alfabet: plain_text += i def enc1(text): ret = "" for i in text: tmp = alfabet.find(i) if tmp != -1: ret += alfabet2[(tmp + 3) % 26] return ret def enc2(t1, t2): ret = "" for i in range(len(t1)): ret += str(ord(t1[i]) + ord(t2[i])) + "," return ret print "You need this:", enc2(parola, enc1(parola)) Output: You need this:201,203,165,195,165,191,205,187,181,191,173,187,173,187,193,199,
    2 points
  4. Am gasit din intamplare un curs de la Stanford care pare destul de bine structurat avand o analiza asupra subiectului atat tehnica cat si non-tehnica. Poate va ajuta: https://crypto.stanford.edu/cs251/
    2 points
  5. da daca mergi tu sa-ti faci dreptate si il bati pe copilul ala gasesc resursele necesare sa te bage pe tine in parnaie. smart.
    1 point
  6. 1 point
  7. Tehnologia informatiei Manual pentru class a IX-a Informatica - Tehnologii asistate de calculator de Mariana Milosescu (Teora) Sisteme de calcul Sisteme de operare Birotica - Word, Excel, Paint Multimedia si Internet Link download: https://www.plustransfer.com/download.php?id=8a8014e3e5297e932d0284d0a91dc829
    1 point
  8. Daca exista plangere prealabila, vor fi amendati (parintii lor, ce plm de amenda sa primeasca un minor) insa nu prea se apuca nimeni sa cerceteze spargeri de vps-uri pe care sunt servere de cs. Trebuie sa priceapa toata lumea ca si politia/parchetul are resurse limitate, si nu le irosesc pe cacaturi de 2 bani.
    1 point
  9. TL;DR; Researchers warn of a new attack which can be carried out in less than 30 seconds and potentially affects millions of laptops globally. As Intel was rushing to roll out patches for Meltdown and Spectre vulnerabilities, security researchers have discovered a new critical security flaw in Intel hardware that could allow hackers to access corporate laptops remotely. Finnish cyber security firm F-Secure reported unsafe and misleading default behaviour within Intel Active Management Technology (AMT) that could allow an attacker to bypass login processes and take complete control over a user's device in less than 30 seconds. Link: https://thehackernews.com/2018/01/intel-amt-vulnerability.html Pe o nota personala, greu inceput de an pentru Intel. Multe "molii" iesite de la naftalina.
    1 point
×
×
  • Create New...