Ransomware is a persistent threat to cybersecurity, leveraging encryption and compression techniques to obscure malicious data, making detection increasingly challenging for traditional systems. The novel approach presented in this article introduces a convolutional neural network (CNN) designed to address the limitations of existing detection methods by efficiently identifying ransomware-affected data even when strong encryption and compression algorithms are employed. Through a threelayer CNN architecture, the proposed method captures both lowlevel and high-level patterns within the file structure, enabling accurate and real-time classification of ransomware-affected files without requiring manual intervention or predefined signatures. Performance evaluations revealed significant improvements over baseline models, with the CNN achieving higher accuracy, precision, and recall, while also reducing processing time for large datasets. This advancement demonstrates the importance of automated machine learning systems in responding to increasingly sophisticated ransomware attacks, providing a scalable and practical solution for real-world applications. The ability of the CNN model to generalize across various ransomware variants further highlights its adaptability, making it an essential tool for organizations seeking to mitigate the risks posed through encrypted and compressed ransomware.