Initial commit: Laravel OSINT platform

Multi-user OSINT investigation tool with owner-controlled per-user and
per-group access grants. Includes Sherlock, theHarvester, crt.sh, WHOIS,
and ip-api.com collectors wired through a pluggable Runner/queue pipeline,
investigation search, and printable/CSV/JSON reporting.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
cedry2k1992
2026-07-20 10:22:05 +03:00
co-authored by Claude Sonnet 5
commit 873699e23e
165 changed files with 18507 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
#[Fillable(['target_id', 'source_id', 'run_by', 'status', 'raw_payload', 'summary', 'error', 'ran_at'])]
class Finding extends Model
{
protected function casts(): array
{
return [
'raw_payload' => 'array',
'ran_at' => 'datetime',
];
}
public function target(): BelongsTo
{
return $this->belongsTo(Target::class);
}
public function source(): BelongsTo
{
return $this->belongsTo(Source::class);
}
public function runByUser(): BelongsTo
{
return $this->belongsTo(User::class, 'run_by');
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['name', 'description', 'owner_id'])]
class Group extends Model
{
use HasFactory;
public function owner(): BelongsTo
{
return $this->belongsTo(User::class, 'owner_id');
}
public function members(): BelongsToMany
{
return $this->belongsToMany(User::class)->withTimestamps();
}
public function investigations(): BelongsToMany
{
return $this->belongsToMany(Investigation::class, 'investigation_group')
->withPivot('role')
->withTimestamps();
}
public function isAccessibleBy(User $user): bool
{
return $this->owner_id === $user->id
|| $this->members()->where('users.id', $user->id)->exists();
}
}
+94
View File
@@ -0,0 +1,94 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['name', 'description', 'owner_id', 'status'])]
class Investigation extends Model
{
use HasFactory;
/**
* Investigations owned by, directly granted to, or group-granted to the user.
* Used for listing; per-item role/edit checks still go through roleFor().
*/
public function scopeAccessibleBy(Builder $query, User $user): Builder
{
return $query->where(function (Builder $q) use ($user) {
$q->where('owner_id', $user->id)
->orWhereHas('users', fn (Builder $q2) => $q2->where('users.id', $user->id))
->orWhereHas('groups', fn (Builder $q2) => $q2->whereIn(
'groups.id',
$user->groups()->pluck('groups.id')
));
});
}
public function owner(): BelongsTo
{
return $this->belongsTo(User::class, 'owner_id');
}
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class)
->withPivot('role')
->withTimestamps();
}
public function groups(): BelongsToMany
{
return $this->belongsToMany(Group::class, 'investigation_group')
->withPivot('role')
->withTimestamps();
}
public function targets(): HasMany
{
return $this->hasMany(Target::class);
}
/**
* The role a user has on this investigation, or null if they have no access.
* Owner implicitly has the 'owner' role; direct grants win over group grants,
* and among group grants 'editor' wins over 'viewer'.
*/
public function roleFor(User $user): ?string
{
if ($this->owner_id === $user->id) {
return 'owner';
}
$directRole = $this->users()->where('users.id', $user->id)->value('investigation_user.role');
if ($directRole !== null) {
return $directRole;
}
$groupRoles = $this->groups()
->whereIn('groups.id', $user->groups()->pluck('groups.id'))
->pluck('investigation_group.role');
if ($groupRoles->isEmpty()) {
return null;
}
return $groupRoles->contains('editor') ? 'editor' : 'viewer';
}
public function isAccessibleBy(User $user): bool
{
return $this->roleFor($user) !== null;
}
public function isEditableBy(User $user): bool
{
return in_array($this->roleFor($user), ['owner', 'editor'], true);
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['key', 'name', 'description', 'target_types', 'runner', 'enabled'])]
class Source extends Model
{
protected function casts(): array
{
return [
'target_types' => 'array',
'enabled' => 'boolean',
];
}
public function findings(): HasMany
{
return $this->hasMany(Finding::class);
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['investigation_id', 'created_by', 'type', 'value', 'notes'])]
class Target extends Model
{
public const TYPES = ['person', 'domain', 'email', 'username', 'ip', 'org'];
/**
* Format validation for the `value` column, per target type.
* Kept in sync with runners that assume a given shape (e.g.
* SherlockRunner's username charset check).
*
* @return array<int, string>
*/
public static function valueRulesFor(string $type): array
{
return match ($type) {
'email' => ['required', 'string', 'email', 'max:255'],
'domain' => ['required', 'string', 'max:255', 'regex:/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/'],
'ip' => ['required', 'ip'],
'username' => ['required', 'string', 'max:255', 'regex:/^[a-zA-Z0-9._-]+$/'],
default => ['required', 'string', 'max:255'],
};
}
public function investigation(): BelongsTo
{
return $this->belongsTo(Investigation::class);
}
public function creator(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
public function findings(): HasMany
{
return $this->hasMany(Finding::class);
}
}
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
#[Fillable(['name', 'email', 'password'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
public function ownedGroups(): HasMany
{
return $this->hasMany(Group::class, 'owner_id');
}
public function groups(): BelongsToMany
{
return $this->belongsToMany(Group::class)->withTimestamps();
}
public function ownedInvestigations(): HasMany
{
return $this->hasMany(Investigation::class, 'owner_id');
}
public function investigations(): BelongsToMany
{
return $this->belongsToMany(Investigation::class)
->withPivot('role')
->withTimestamps();
}
}