Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bind rule to the flutter App #35

Merged
merged 5 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions ostorlab_insecure_flutter_app/lib/bugs/bind.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'dart:io';
import 'package:ostorlab_insecure_flutter_app/bug_rule.dart';

/// A [BugRule] that triggers the use of bind.
class BindRule extends BugRule {
/// The tag used to identify instances of this rule.
static const String _tag = 'BindRule';

/// Returns a description of this [BugRule] implementation.
@override
String get description => 'Bind local host to a port';

/// Trigger the [BugRule] by starting an HTTP server that listens for connections and binds to a port.
@override
Future<void> run(String input) async {
var port = (input != "") ? int.parse(input) : 4450;

try {
var server = await HttpServer.bind('localhost', port);

print('Server listening on port $port');
await for (var request in server) {
request.response
..write('Server running on port $port')
..close();
}
} catch (e) {
print('Failed to bind server: $e');
}
}
}
2 changes: 2 additions & 0 deletions ostorlab_insecure_flutter_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:ostorlab_insecure_flutter_app/bugs/webview_insecure_settings.dar
import 'package:ostorlab_insecure_flutter_app/bugs/oracle_padding.dart';
import 'package:ostorlab_insecure_flutter_app/bugs/biometric_none_cryptobject.dart';
import 'package:ostorlab_insecure_flutter_app/bugs/reflection_api.dart';
import 'package:ostorlab_insecure_flutter_app/bugs/bind.dart';

import 'package:receive_intent/receive_intent.dart' as receive_intent;

Expand Down Expand Up @@ -102,6 +103,7 @@ class _MyHomePageState extends State<MyHomePage> {
caller.addRule(OraclePadding());
caller.addRule(BiometricNoneCryptObject());
caller.addRule(ReflectionApi());
caller.addRule(BindRule());

try {
await caller.callRules(input);
Expand Down
Loading