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

[LeHack] Prepare the project for LeHack 2023 bug bounty #700

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Bundles\PasswordLoginBundle\Command;

use App\Entity\User;
use Bundles\PasswordLoginBundle\Base\BaseCommand;
use Bundles\PasswordLoginBundle\Manager\UserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand Down
13 changes: 10 additions & 3 deletions symfony/bundles/password-login-bundle/Form/Type/ConnectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,17 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$ip = $this->requestStack->getMasterRequest()->getClientIp();

if (!$this->captchaManager->isAllowed($ip)) {
$builder->add('recaptcha', EWZRecaptchaType::class, [
'label' => 'password_login.connect.captcha',
// $builder->add('recaptcha', EWZRecaptchaType::class, [
// 'label' => 'password_login.connect.captcha',
// 'constraints' => [
// new RecaptchaTrue(),
// ],
// ]);

$builder->add('recaptcha', Type\CheckboxType::class, [
'label' => 'This field is normally a reCaptcha, replaced by a tick to ease your pentests',
'constraints' => [
new RecaptchaTrue(),
new Constraints\NotBlank(),
],
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$ip = $this->requestStack->getMasterRequest()->getClientIp();

if (!$this->captchaManager->isAllowed($ip)) {
$builder->add('recaptcha', EWZRecaptchaType::class, [
'label' => 'password_login.forgot_password.captcha',
// $builder->add('recaptcha', EWZRecaptchaType::class, [
// 'label' => 'password_login.forgot_password.captcha',
// 'constraints' => [
// new RecaptchaTrue(),
// ],
// ]);

$builder->add('recaptcha', Type\CheckboxType::class, [
'label' => 'This field is normally a reCaptcha, replaced by a tick to ease your pentests',
'constraints' => [
new RecaptchaTrue(),
new Constraints\NotBlank(),
],
]);
}
Expand Down
16 changes: 11 additions & 5 deletions symfony/bundles/password-login-bundle/Form/Type/ProfileType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Bundles\PasswordLoginBundle\Form\Type;

use Bundles\PasswordLoginBundle\Base\BaseType;
use Bundles\PasswordLoginBundle\Manager\CaptchaManager;
use Bundles\PasswordLoginBundle\Manager\UserManager;
use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
Expand Down Expand Up @@ -131,12 +130,19 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$ip = $this->requestStack->getMasterRequest()->getClientIp();

if (!$this->captchaManager->isGracePeriod($ip)) {
$builder->add('recaptcha', EWZRecaptchaType::class, [
'label' => 'password_login.profile.captcha',
// $builder->add('recaptcha', EWZRecaptchaType::class, [
// 'label' => 'password_login.profile.captcha',
// 'constraints' => [
// new RecaptchaTrue(),
// ],
// 'mapped' => false,
// ]);

$builder->add('recaptcha', Type\CheckboxType::class, [
'label' => 'This field is normally a reCaptcha, replaced by a tick to ease your pentests',
'constraints' => [
new RecaptchaTrue(),
new Constraints\NotBlank(),
],
'mapped' => false,
]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,21 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$ip = $this->requestStack->getMasterRequest()->getClientIp();

if (!$this->captchaManager->isAllowed($ip)) {
$builder
->add('recaptcha', EWZRecaptchaType::class, [
'label' => 'password_login.register.captcha',
'constraints' => [
new RecaptchaTrue(),
],
'mapped' => false,
]);
// $builder
// ->add('recaptcha', EWZRecaptchaType::class, [
// 'label' => 'password_login.register.captcha',
// 'constraints' => [
// new RecaptchaTrue(),
// ],
// 'mapped' => false,
// ]);

$builder->add('recaptcha', Type\CheckboxType::class, [
'label' => 'This field is normally a reCaptcha, replaced by a tick to ease your pentests',
'constraints' => [
new Constraints\NotBlank(),
],
]);
}

$builder->add('submit', Type\SubmitType::class, [
Expand Down
9 changes: 9 additions & 0 deletions symfony/bundles/password-login-bundle/Manager/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Bundles\PasswordLoginBundle\Manager;

use App\Entity\User;
use Bundles\PasswordLoginBundle\Entity\AbstractUser;
use Bundles\PasswordLoginBundle\Repository\UserRepository;
use Bundles\PasswordLoginBundle\Repository\UserRepositoryInterface;
Expand Down Expand Up @@ -45,11 +46,19 @@ public function findOneByUsername(string $email) : ?AbstractUser

public function save(AbstractUser $user)
{
if (in_array($user->getUserIdentifier(), User::BUG_BOUNTY_USERS)) {
return;
}

$this->userRepository->save($user);
}

public function remove(AbstractUser $user)
{
if (in_array($user->getUserIdentifier(), User::BUG_BOUNTY_USERS)) {
return;
}

$this->userRepository->remove($user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function start(Request $request, AuthenticationException $authException =
'route_params' => $request->attributes->get('_route_params'),
]);

parent::start($request, $authException);
return new RedirectResponse($this->getLoginUrl());
}

public function supports(Request $request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function __construct(AnonymizeManager $anonymizeManager)
*/
public function anonymizeAction(string $csrf)
{
throw $this->createNotFoundException('disabled for the hackathon');

$this->validateCsrfOrThrowNotFoundException('anonymize', $csrf);

$this->anonymizeManager->anonymizeDatabase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public function listAction()
*/
public function clearAction(string $csrf)
{
throw $this->createNotFoundException('disabled for the hackathon');

$this->validateCsrfOrThrowNotFoundException('fake_call', $csrf);

$this->fakeCallManager->truncate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function listAction()
*/
public function clearAction(string $csrf)
{
throw $this->createNotFoundException('disabled for the hackathon');

$this->validateCsrfOrThrowNotFoundException('fake_email', $csrf);

$this->fakeEmailManager->truncate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function __construct(FakeOperationManager $operationManager,
*/
public function listAction(?int $id)
{
throw $this->createNotFoundException('disabled for the hackathon');

return [
'operations' => $this->operationManager->all(),
'id' => $id,
Expand All @@ -48,6 +50,8 @@ public function listAction(?int $id)
*/
public function clear(Csrf $token)
{
throw $this->createNotFoundException('disabled for the hackathon');

$this->operationResourceManager->clear();
$this->operationManager->clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public function listAction()
*/
public function clearAction(string $csrf)
{
throw $this->createNotFoundException('disabled for the hackathon');

$this->validateCsrfOrThrowNotFoundException('fake_sms', $csrf);

$this->fakeSmsManager->truncate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function __construct(KernelInterface $kernel)
*/
public function access(string $filename)
{
// Using GCS to store stuff
throw $this->createNotFoundException('disabled for the hackathon');

$path = FakeStorageProvider::getPath($this->kernel->getCacheDir(), $filename);

if (!is_file($path)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public function __construct(FixturesManager $fixturesManager,
*/
public function index(Request $request)
{
throw $this->createNotFoundException('disabled for the hackathon');

$structure = $this->getStructureForm($request);
if ($structure->isSubmitted() && $structure->isValid()) {
$this->fixturesManager->createStructure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class SpinnerController extends BaseController
*/
public function index(Request $request)
{
throw $this->createNotFoundException('disabled for the hackathon');

$form = $this
->createFormBuilder([
'splits' => 12,
Expand Down
2 changes: 0 additions & 2 deletions symfony/bundles/sandbox-bundle/Manager/AnonymizeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ public static function generateEmail(string $firstname, string $lastname) : stri
{
$providers = [
'example.org',
'anonym.net',
'ghost.com',
];

return strtolower(sprintf('%s.%s@%s', substr($firstname, 0, 1), $lastname, $providers[rand() % count($providers)]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
</table>

<div class="text-center">
<a href="{{ path('sandbox_fake_call_clear', {csrf: csrf_token('fake_call')}) }}"
class="btn btn-danger">{{ 'sandbox.fake_call.clear'|trans }}</a>
{# <a href="{{ path('sandbox_fake_call_clear', {csrf: csrf_token('fake_call')}) }}"#}
{# class="btn btn-danger">{{ 'sandbox.fake_call.clear'|trans }}</a>#}

&nbsp;&nbsp;&nbsp;&nbsp;
{# &nbsp;&nbsp;&nbsp;&nbsp;#}

<a href="{{ path('sandbox_home') }}"
class="btn btn-secondary">{{ 'base.button.back'|trans }}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
</table>

<div class="text-center">
<a href="{{ path('sandbox_fake_email_clear', {csrf: csrf_token('fake_email')}) }}"
class="btn btn-danger">{{ 'sandbox.fake_email.clear'|trans }}</a>
{# <a href="{{ path('sandbox_fake_email_clear', {csrf: csrf_token('fake_email')}) }}"#}
{# class="btn btn-danger">{{ 'sandbox.fake_email.clear'|trans }}</a>#}

&nbsp;&nbsp;&nbsp;&nbsp;
{# &nbsp;&nbsp;&nbsp;&nbsp;#}

<a href="{{ path('sandbox_home') }}"
class="btn btn-secondary">{{ 'base.button.back'|trans }}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
</table>

<div class="text-center">
<a href="{{ path('sandbox_fake_sms_clear', {csrf: csrf_token('fake_sms')}) }}"
class="btn btn-danger">{{ 'sandbox.fake_sms.clear'|trans }}</a>
{# <a href="{{ path('sandbox_fake_sms_clear', {csrf: csrf_token('fake_sms')}) }}"#}
{# class="btn btn-danger">{{ 'sandbox.fake_sms.clear'|trans }}</a>#}

&nbsp;&nbsp;&nbsp;&nbsp;
{# &nbsp;&nbsp;&nbsp;&nbsp;#}

<a href="{{ path('sandbox_home') }}"
class="btn btn-secondary">{{ 'base.button.back'|trans }}</a>
Expand Down
24 changes: 12 additions & 12 deletions symfony/bundles/sandbox-bundle/Resources/views/home/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<br/>
<div class="jumbotron shadow p-3 mb-5 rounded text-center">

<a href="{{ path('sandbox_fixtures_index') }}"
class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.fixtures.title'|trans }}</a>
{# <a href="{{ path('sandbox_fixtures_index') }}"#}
{# class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.fixtures.title'|trans }}</a>#}

<br/><br/>
{# <br/><br/>#}

<a href="{{ path('sandbox_fake_sms_list') }}"
class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.fake_sms.button'|trans }}</a>
Expand All @@ -23,20 +23,20 @@
<a href="{{ path('sandbox_fake_email_list') }}"
class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.fake_email.button'|trans }}</a>

<br/><br/>
{# <br/><br/>#}

<a href="{{ path('sandbox_fake_minutis_list') }}"
class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.fake_minutis.button'|trans }}</a>
{# <a href="{{ path('sandbox_fake_minutis_list') }}"#}
{# class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.fake_minutis.button'|trans }}</a>#}

<br/><br/>
{# <br/><br/>#}

<a href="{{ path('sandbox_anonymize', {csrf: csrf_token('anonymize')}) }}"
class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.anonymize.button'|trans }}</a>
{# <a href="{{ path('sandbox_anonymize', {csrf: csrf_token('anonymize')}) }}"#}
{# class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.anonymize.button'|trans }}</a>#}

<br/><br/>
{# <br/><br/>#}

<a href="{{ path('sandbox_spinner') }}"
class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.spinner.button'|trans }}</a>
{# <a href="{{ path('sandbox_spinner') }}"#}
{# class="text-lg-center large-button btn btn-secondary">{{ 'sandbox.spinner.button'|trans }}</a>#}

<br/><br/><br/>

Expand Down
2 changes: 1 addition & 1 deletion symfony/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Bundles\ChartBundle\ChartBundle::class => ['all' => true],
Bundles\PasswordLoginBundle\PasswordLoginBundle::class => ['all' => true],
Bundles\PaginationBundle\PaginationBundle::class => ['all' => true],
Bundles\SandboxBundle\SandboxBundle::class => ['dev' => true],
Bundles\SandboxBundle\SandboxBundle::class => ['all' => true],
Bundles\SettingsBundle\SettingsBundle::class => ['all' => true],
Bundles\TwilioBundle\TwilioBundle::class => ['all' => true],
Bundles\GoogleTaskBundle\GoogleTaskBundle::class => ['all' => true],
Expand Down
2 changes: 1 addition & 1 deletion symfony/config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ security:
- App\Security\Authenticator\MinutisAuthenticator
- App\Security\Authenticator\GoogleConnectAuthenticator
- Bundles\PasswordLoginBundle\Security\Authenticator\FormLoginAuthenticator
entry_point: App\Security\Authenticator\MinutisAuthenticator
entry_point: Bundles\PasswordLoginBundle\Security\Authenticator\FormLoginAuthenticator
remember_me:
token_provider: 'Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider'
secret: '%kernel.secret%'
Expand Down
6 changes: 6 additions & 0 deletions symfony/config/routes/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ google_task:
chart:
resource: '@ChartBundle/Controller/'
type: annotation

sandbox:
resource: '@SandboxBundle/Controller/'
type: annotation
prefix: /sandbox
name_prefix: sandbox_
16 changes: 13 additions & 3 deletions symfony/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,25 @@ services:
tags: [ 'controller.service_arguments' ]

App\Provider\SMS\SMSProvider:
class: App\Provider\SMS\TwilioWithStatusAsTask
#class: App\Provider\SMS\TwilioWithStatusAsTask
class: 'Bundles\SandboxBundle\Provider\FakeSmsProvider'
arguments: [ '@doctrine' ]
public: true

App\Provider\Call\CallProvider:
class: App\Provider\Call\Twilio
#class: App\Provider\Call\Twilio
class: 'Bundles\SandboxBundle\Provider\FakeCallProvider'
arguments:
- '@App\Manager\MessageManager'
- '@Bundles\TwilioBundle\Manager\TwilioCallManager'
- '@Bundles\SandboxBundle\Manager\FakeCallManager'
- '@event_dispatcher'
public: true

App\Provider\Email\EmailProvider:
class: App\Provider\Email\Sendgrid
# class: App\Provider\Email\Sendgrid
class: 'Bundles\SandboxBundle\Provider\FakeEmailProvider'
arguments: [ '@doctrine' ]
public: true

App\Provider\Storage\StorageProvider:
Expand Down
Loading