Skip to content

Commit

Permalink
Updated Version with Security Scanner and AWS work
Browse files Browse the repository at this point in the history
  • Loading branch information
azu-josh committed Aug 27, 2024
1 parent d6227d4 commit 04fbec0
Show file tree
Hide file tree
Showing 15 changed files with 4,816 additions and 2,887 deletions.
7 changes: 5 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
MONGO_URI=mongodb+srv://dbAzu:[email protected]/dbAzu?retryWrites=true&w=majority
MONGO_URI=mongodb+srv://dbAzu:[email protected]/?retryWrites=true&w=majority&appName=Cluster0
JWT_SECRET=Alfred_Azu
SKIP_PREFLIGHT_CHECK=true
API_URL=http://172.20.10.4:8081
NODE_ENV=development
PORT=5000
PORT=5000
AWS_ACCESS_KEY=AKIATOMKLEFOGOJ3SRVO
AWS_SECRET_ACCESS_KEY=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
AWS_REGION=us-east-1
5 changes: 5 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />

<uses-permission android:name="android.permission.READ_PHONE_STATE" />


<!-- Notification Permissions -->
<uses-permission android:name="android.permission.VIBRATE"/>
Expand Down
7,334 changes: 4,482 additions & 2,852 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
"web": "expo start --web"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.633.0",
"@aws-sdk/credential-provider-node": "^3.632.0",
"@expo/metro-runtime": "~3.2.1",
"@expo/react-native-action-sheet": "^4.1.0",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-community/netinfo": "^11.3.2",
"@react-native-firebase/app": "^20.3.0",
"@react-native-firebase/messaging": "^20.3.0",
"@react-native-firebase/storage": "^20.1.0",
"@react-navigation/bottom-tabs": "^6.5.20",
"@react-navigation/drawer": "^6.6.15",
"@react-navigation/native": "^6.1.17",
"@react-navigation/stack": "^6.3.29",
"aws-sdk": "^2.1677.0",
"aws-sdk": "^2.1683.0",
"axios": "^1.7.2",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
Expand Down Expand Up @@ -51,6 +54,7 @@
"react-native-image-picker": "^7.1.2",
"react-native-keychain": "^8.2.0",
"react-native-local-auth": "^1.7.0",
"react-native-netinfo": "^1.1.0",
"react-native-permissions": "^4.1.5",
"react-native-reanimated": "~3.10.1",
"react-native-router-flux": "^4.3.1",
Expand Down
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

const express = require('express');
const mongoose = require('mongoose');
const dotenv = require('dotenv');
Expand Down
1 change: 1 addition & 0 deletions src/Component/AuthContext.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import React, { createContext, useState, useContext } from 'react';
import axios from 'axios';

Expand Down
2 changes: 1 addition & 1 deletion src/Component/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Home = ({ navigation }) => {
<Text style={styles.homeCardTitle}>APP PERMISSIONS MANAGER</Text>
</View>
<View style={styles.homeCardWrapper}>
<TouchableOpacity style={styles.homeCard} onPress={() => navigation.navigate('PrivacyScanner')}>
<TouchableOpacity style={styles.homeCard} onPress={() => navigation.navigate('SecurityScanner')}>
<Image source={PrivacyScannerImage} style={styles.homeCardImage} />
</TouchableOpacity>
<Text style={styles.homeCardTitle}>PRIVACY SCANNER</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/Component/Navigators/HomeStackNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import LoginC from '../LoginC';
import Register from '../Register';
import SplashScreen from '../SplashScreen';
import SecureVault from '../SecureVault'; // Ensure SecureVault is imported
import SecurityScanner from '../PAGES/SecurityScanner';

const Stack = createStackNavigator();

Expand All @@ -16,6 +17,7 @@ const HomeStackNavigator = () => {
<Stack.Screen name="Login" component={LoginC} />
<Stack.Screen name="Register" component={Register} />
<Stack.Screen name="SecureVault" component={SecureVault} /> {/* Register SecureVault */}
<Stack.Screen name="SecurityScanner" component={SecurityScanner}/>
</Stack.Navigator>
);
};
Expand Down
151 changes: 151 additions & 0 deletions src/Component/PAGES/SecurityScanner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, Button, Alert, ActivityIndicator, StyleSheet, SafeAreaView } from 'react-native';
//import DeviceInfo from 'react-native-device-info';
import NetInfo from '@react-native-community/netinfo';
import AWS from 'aws-sdk';


// AWS Configuration (Set up with your credentials)
AWS.config.update({
region: 'us-east-1', // Replace with your AWS region
accessKeyId: 'AKIATOMKLEFOGOJ3SRVO', // Replace with your AWS Access Key
secretAccessKey: 'cAqMdruPF3ouP+VGIBmnQTdApQMhb2dbKUNYGRiH', // Replace with your AWS Secret Key
});

const SecurityScanner = () => {
const [installedApps, setInstalledApps] = useState([]);
const [networkInfo, setNetworkInfo] = useState({});
const [loading, setLoading] = useState(true);
const [alerts, setAlerts] = useState([]);

useEffect(() => {
checkInstalledApps();
monitorNetworkActivity();
}, []);

const checkInstalledApps = async () => {
try {
const apps = await DeviceInfo.getInstalledApplications();
setInstalledApps(apps);
setLoading(false);
} catch (error) {
console.error('Error fetching installed apps:', error);
setLoading(false);
}
};

const monitorNetworkActivity = () => {
const unsubscribe = NetInfo.addEventListener((state) => {
if (state.isConnected) {
const isSuspicious = checkForMaliciousDomains(state.details.ssid);
if (isSuspicious) {
handleSuspiciousActivity(`Suspicious network detected: ${state.details.ssid}`);
}
}
setNetworkInfo(state);
});

return () => unsubscribe();
};

const checkForMaliciousDomains = (ssid) => {
const knownMaliciousDomains = ['malicious.com', 'phishing.com'];
return knownMaliciousDomains.includes(ssid);
};

const handleSuspiciousActivity = (activityDetails) => {
setAlerts((prevAlerts) => [...prevAlerts, `Suspicious activity detected: ${activityDetails}`]);
uploadLogsToS3(`Suspicious activity: ${activityDetails}`);
};

const uploadLogsToS3 = async (logContent) => {
const s3 = new AWS.S3();
const params = {
Bucket: 'your-s3-bucket-name',
Key: `logs/${Date.now()}.txt`,
Body: logContent,
ContentType: 'text/plain',
};

try {
await s3.upload(params).promise();
Alert.alert('Logs Uploaded', 'Security logs have been uploaded to S3.');
} catch (error) {
console.error('Error uploading logs to S3:', error);
}
};

const renderAppItem = ({ item }) => (
<View style={styles.appItem}>
<Text style={styles.appName}>{item}</Text>
<Button title="Block" onPress={() => handleBlockApp(item)} color="#ff0000" />
</View>
);

return (
<View style={styles.container}>
<Text style={styles.title}>Security Scanner</Text>
{loading ? (
<ActivityIndicator size="large" color="#007bff" />
) : (
<>
<Text style={styles.sectionTitle}>Installed Applications:</Text>
<FlatList
data={installedApps}
keyExtractor={(item) => item}
renderItem={renderAppItem}
/>
<Text style={styles.sectionTitle}>Network Status:</Text>
<Text>{networkInfo.isConnected ? 'Connected' : 'Not Connected'}</Text>
<Text>SSID: {networkInfo.details ? networkInfo.details.ssid : 'N/A'}</Text>
<Text style={styles.sectionTitle}>Alerts:</Text>
{alerts.length === 0 ? (
<Text>No Alerts</Text>
) : (
alerts.map((alert, index) => (
<Text key={index} style={styles.alertText}>
{alert}
</Text>
))
)}
</>
)}
</View>
);
};

const styles = StyleSheet.create({
container: {
flex: 1,
padding: 20,
backgroundColor: '#fff',
},
title: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
},
sectionTitle: {
fontSize: 18,
fontWeight: 'bold',
marginTop: 20,
marginBottom: 10,
},
appItem: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingVertical: 10,
borderBottomWidth: 1,
borderBottomColor: '#eee',
},
appName: {
fontSize: 16,
},
alertText: {
color: 'red',
marginVertical: 5,
},
});

export default SecurityScanner;
2 changes: 1 addition & 1 deletion src/Component/Register.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,4 @@ const styles = StyleSheet.create({
},
});

export default Register;
export default Register;
70 changes: 65 additions & 5 deletions src/Component/SecureVault.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import Icon from 'react-native-vector-icons/Ionicons';
import * as ImagePicker from 'expo-image-picker';
import { useActionSheet } from '@expo/react-native-action-sheet';
import AWS from 'aws-sdk';
import * as LocalAuthentication from 'expo-local-authentication'

const SecureVault = () => {
const navigation = useNavigation();
const { showActionSheetWithOptions } = useActionSheet();
const [photos, setPhotos] = useState([]);
const [uploading, setUploading] = useState(false);
const [isBiometricsSupported, setIsBiometricsSupported] = useState(false);



Expand All @@ -22,12 +24,70 @@ const SecureVault = () => {
"ExposeHeaders": []
}
]

//for my face id detection and fingerpring config
useEffect(()=>{
(async ()=> {
const compatible = await LocalAuthentication.hasHardwareAsync();
setIsBiometricsSupported(compatible);
})();
});
const fallBackToDefualtAuth = () => {
console.log ('fall back to password authentication');

};
const alertComponent = (title, mess, btnTxt, btnFunc) => {
return Alert.alert(title, mess, [
{
text:btnTxt,
onPress: btnFunc,
}
])
}

const handleBiometricAuth = async ()=> {
//check if it supports bio
const isBiometricAvailable =await LocalAuthentication.hasHardwareAsync();
//Go back if Bio is missing
if (!isBiometricAvailable)
return alertComponet (
'KINDLY ENTER PIN TO CONTINUE',
'FACE ID OR FINGERPRINT ISNT SUPPORTED',
'Ok',
()=>fallBackToDefualtAuth()
);
//Check what Bio is Available
let supportedBiometrics;
is (isBiometricAvailable)
supportedBiometrics = await LocalAuthentication.supportedAuthenticationTypesAsync()

//check saved Bio locally
const savedBiometrics = await LocalAuthentication.isEnrolledAsync();
if (!savedBiometrics)
return alertComponent(
'Biometric Not Found',
'Please use PIN to login',
'Ok',
()=> fallBackToDefualtAuth()
);
//authenicate with Bio
const biometricAuth = await LocalAuthentication.authenticateAsync({
promptMessage: 'Login with FcaeID or TouchID',
cancelLabel: 'cancel',
disableDeviceFallback: true,
});
// Log the to SecureVAULT on successs
if (biometricAuth) {TwoButtonAlet()};
console.log ({isBiometricAvailable});
console.log ({supportedBiometrics});
console.log({savedBiometrics});
console.log ({biometricAuth});
};

// Configure AWS SDK
const s3 = new AWS.S3({
accessKeyId: 'AKIATOMKLEFOGOJ3SRVO', // Replace with your actual access key, these are suposed to be encrypted to avoid hacking
secretAccessKey: 'cAqMdruPF3ouP+VGIBmnQTdApQMhb2dbKUNYGRiH', // Replace with your actual secret access key
region: 'US East (N. Virginia) us-east-1', // Replace with your bucket's region
region: 'us-east-1', // Replace with your bucket's region
});

const uploadImageToS3 = async (uri) => {
Expand Down Expand Up @@ -74,7 +134,7 @@ const SecureVault = () => {
});

if (!result.canceled) {
await uploadImageToS3(result.uri);
await uploadImageToS3(result.assets[0].uri);
}
} else if (buttonIndex === 2) {
let result = await ImagePicker.launchCameraAsync({
Expand All @@ -84,7 +144,7 @@ const SecureVault = () => {
});

if (!result.canceled) {
await uploadImageToS3(result.uri);
await uploadImageToS3(result.assets[0].uri);
}
}
}
Expand Down Expand Up @@ -203,4 +263,4 @@ const styles = StyleSheet.create({
},
});

export default SecureVault;
export default SecureVault;
Binary file not shown.
11 changes: 11 additions & 0 deletions src/backend/awsConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import AWS from 'aws-sdk';
import Config from 'react-native-config'; // Assuming you're using react-native-config

AWS.config.update({
accessKeyId: Config.AWS_ACCESS_KEY,
secretAccessKey: Config.AWS_SECRET_ACCESS_KEY,
region: Config.AWS_REGION
});

export const s3 = new AWS.S3();
export const lambda = new AWS.Lambda();
Loading

0 comments on commit 04fbec0

Please sign in to comment.