Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Enhancing Web Application Security for Promotional Activities

Tech 2

Promotional web pages, such as those for claiming red packets, coupons, voting, or lotteries, are designed to offer random rewards to users. However, malicious actors can exploit direct API calls to manipulate outcomes, creating unfair advantages over legitimate participants.

Securing Login Credentials with SHA-256 Hashing

When transmitting passwords, it's advisable to use hashing algorithms like SHA-256 instead of symmetric encryption methods such as AES. Hashing provides one-way, irreversible conversion, whereas symetric encryption is reversible and requires key management.

Comparison of Security Methods

  • AES Encryptoin: Security depends on key secrecy and length, with AES-256 offering robust protection. However, it's reversible and necessitates secure key storage.
  • SHA-256 Hashing: This algorithm generates a fixed-size hash from input data, making it highly resistant to collisions. It's non-reversible and doesn't require key storage, making it suitable for password prtoection.
  • MD5 Hashing: Once popular, MD5 is now deprecated for security-critical applications due to vulnerabilities like collision attacks.

Implementing Encryption with Crypto-JS

Crypto-JS is a JavaScript library that supports various cryptographic algorithms, including AES and SHA-256. It's modular, easy to use, and compatible with both browser and Node.js environments.

Example of using SHA-256 for password hashing:

const CryptoJS = require('crypto-js');

function hashPassword(password) {
    return CryptoJS.SHA256(password).toString();
}

const userPassword = 'securePass123';
const hashedPassword = hashPassword(userPassword);
console.log('Hashed Password:', hashedPassword);

Configuring Anti-Crawling Measures in Vue.js

To prevent automated scraping, configure a robots.txt file in you're Vue.js project. Add this to vue.config.js:

module.exports = {
    chainWebpack: config => {
        config.plugin('copy').tap(args => {
            args[0].patterns.push({
                from: 'public/robots.txt',
                to: '.'
            });
            return args;
        });
    }
};

Preventing Developer Tools Access

While anti-crawling helps, client-side code remains vulnerable to debugging. Implement these techniques to deter unauthorized access:

Disabling Keyboard Shortcuts and Context Menu

Monitor for developer tool shortcuts and right-click actions to close the page:

document.addEventListener('keydown', function(event) {
    if (event.key === 'F12' || 
        (event.ctrlKey && event.shiftKey && event.key === 'I') || 
        (event.ctrlKey && event.key === 'S')) {
        event.preventDefault();
        window.close();
    }
});

document.addEventListener('contextmenu', function(event) {
    event.preventDefault();
    window.close();
});

Detecting Window Resize Events

Track changes in window dimensions that may indicate developer tool are open:

const initialHeight = window.innerHeight;
const initialWidth = window.innerWidth;

window.addEventListener('resize', function() {
    if (window.innerHeight !== initialHeight || window.innerWidth !== initialWidth) {
        window.close();
    }
});

Overriding Console Methods

Modify console functions to disrupt debugging attempts:

console.log = function() {};
console.warn = function() {};
console.error = function() {};

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.