Skip to content

Conversation

@jackdwalker
Copy link
Contributor

Reverts #1958

@jackdwalker jackdwalker linked an issue Jul 9, 2020 that may be closed by this pull request
@bcoles
Copy link
Collaborator

bcoles commented Jul 9, 2020

Perhaps a better alternative. Ancient jQuery code which should work on most browsers using the version of jQuery bundled in the BeEF hook.

<html>
  <head>
    <script src="jquery-1.12.4.min.js"></script>
  </head>
  <body>
    <script>
      var names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"];
      var uniqueNames = [];
      $.each(names, function(i, el){
          if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
      });
      alert(uniqueNames);
    </script>
  </body>
</html>

@bcoles
Copy link
Collaborator

bcoles commented Jul 9, 2020

The alternative code above works on Firefox and Chrome (with slight modification).

I was also able to patch the existing code by using $j instead of $ :

        function unique(array) {
          return $j.grep(array, function(el, index) {
            return index === $j.inArray(el, array);
          });
        }

The patched code works on Firefox, Chrome, and IE 8.

@bcoles
Copy link
Collaborator

bcoles commented Jul 9, 2020

PR #1966 up as an alternative. Not tested thoroughly.

@jackdwalker
Copy link
Contributor Author

jackdwalker commented Jul 9, 2020

I think your alternative is a better solution than reverting - happy to add the suggested simpler solution from that thread at a later point. Commented on your PR.

My only hesitation is due to lack of thorough testing (on my behalf) causing this issue to be introduced in the first place, and I can't test #1966 thoroughly right now. Not on a machine right now where I have access to the environments on my standard workstation.

@bcoles
Copy link
Collaborator

bcoles commented Jul 9, 2020

I think your alternative is a better solution. Commented over there. Only hesitant because the issue was introduced in the first place due to less than thorough testing, and I can't test this thoroughly right now. Not on a machine right now where I have access to the environments on my standard workstation.

I confirmed that the hook works on IE8 and a slightly outdated Firefox and slightly outdated Chrome. No testing beyond that.

@jackdwalker
Copy link
Contributor Author

I confirmed that the hook works on IE8 and a slightly outdated Firefox and slightly outdated Chrome. No testing beyond that.

Understood. I think despite my reservations your PR is probably the way forward. If issues continue to ensue I'll revert (will leave #1965 up for a little while to save the pain of the tests running again) and find a new solution and implement that into the core hook API (which I'll make an issue for once #1966 is merged).

@jackdwalker
Copy link
Contributor Author

BeEF appears stable. This revert does is not necessary. Closing for now.

@wheatley wheatley deleted the revert-1958-replace_array_prototype_unique branch September 4, 2021 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot hook any browsers except firefox

3 participants